mirror of
https://github.com/corda/corda.git
synced 2025-06-14 13:18:18 +00:00
various refinements to network implementation
The main idea is to make DatagramChannel and *SocketChannel behave in a way that more closely matches the standard, e.g. allow binding sockets to addresses without necessarily listening on those addresses and accept null addresses where appropriate. It also avoids multiple redundant DNS lookups. This commit also implements CharBuffer and BindException, and adds the Readable interface.
This commit is contained in:
@ -66,10 +66,10 @@ public class ServerSocketChannel extends SelectableChannel {
|
||||
}
|
||||
}
|
||||
|
||||
private int doListen(String host, int port) throws IOException {
|
||||
private void doListen(int socket, int host, int port) throws IOException {
|
||||
Socket.init();
|
||||
|
||||
return natDoListen(host, port);
|
||||
natDoListen(socket, host, port);
|
||||
}
|
||||
|
||||
public class Handle extends ServerSocket {
|
||||
@ -82,11 +82,10 @@ public class ServerSocketChannel extends SelectableChannel {
|
||||
} catch (ClassCastException e) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
channel.socket = doListen(a.getHostName(), a.getPort());
|
||||
channel.configureBlocking(channel.isBlocking());
|
||||
doListen(channel.socket, a.getAddress().getRawAddress(), a.getPort());
|
||||
}
|
||||
}
|
||||
|
||||
private static native int natDoAccept(int socket) throws IOException;
|
||||
private static native int natDoListen(String host, int port) throws IOException;
|
||||
private static native void natDoListen(int socket, int host, int port) throws IOException;
|
||||
}
|
||||
|
Reference in New Issue
Block a user