socketchannel problem
String hostname = null;
public PeerConnection(String host) throws IOException {
hostname = host;
}
public void run () {
try {
SocketChannel csocket = SocketChannel.open();
csocket.configureBlocking(false);
csocket.connect(new InetSocketAddress(hostname, 5432));
csocket.register(selector, SelectionKey.OP_CONNECT|SelectionKey.OP_READ|SelectionKey.OP_WRITE);
System.out.println(csocket.isConnected());
} catch (UnknownHostException e) {
System.err.println("Don't know about host: " + hostname + ".");
System.exit(1);
} catch (IOException e) {
System.err.println("Couldn't get I/O for the connection to peer " + hostname + ".");
System.exit(1);
}
}
}
This code connects to the server, but this line:
System.out.println(csocket.isConnected());
it prints false, any ideas why guys?

