|
|
|
|
|
|
|
|
Selector selector = Selector.open(); |
|
|
Selector selector = Selector.open(); |
|
|
SelectionKey connect_key = |
|
|
SelectionKey connect_key = |
|
|
sock.socket().getChannel().register(selector, SelectionKey.OP_CONNECT); |
|
|
sock.socket().getChannel().register(selector, SelectionKey.OP_CONNECT); |
|
|
// Try for the connection for 250ms |
|
|
|
|
|
while (selector.select(250) > 0) { |
|
|
|
|
|
|
|
|
// Try for the connection for 3000ms |
|
|
|
|
|
while (selector.select(3000) > 0) { |
|
|
while (!result) { |
|
|
while (!result) { |
|
|
|
|
|
|
|
|
Set keys = selector.selectedKeys(); |
|
|
Set keys = selector.selectedKeys(); |