182 |
// FIXME: Handle blocking/non-blocking mode. |
// FIXME: Handle blocking/non-blocking mode. |
183 |
|
|
184 |
Selector selector = provider().openSelector(); |
Selector selector = provider().openSelector(); |
185 |
register (selector, SelectionKey.OP_CONNECT); |
register(selector, SelectionKey.OP_CONNECT); |
186 |
|
|
187 |
if (isBlocking()) |
if (isBlocking()) |
188 |
{ |
{ |
216 |
return socket; |
return socket; |
217 |
} |
} |
218 |
|
|
219 |
public int read (ByteBuffer dst) throws IOException |
public int read(ByteBuffer dst) throws IOException |
220 |
{ |
{ |
221 |
if (!isConnected()) |
if (!isConnected()) |
222 |
throw new NotYetConnectedException(); |
throw new NotYetConnectedException(); |
227 |
int available = input.available(); |
int available = input.available(); |
228 |
int len = dst.capacity() - dst.position(); |
int len = dst.capacity() - dst.position(); |
229 |
|
|
230 |
if (available == 0) |
if (! isBlocking() && available == 0) |
231 |
return 0; |
return 0; |
232 |
|
|
233 |
if (len > available) |
if (len > available) |