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:
Joel Dice
2014-03-28 12:30:20 -06:00
parent 1e1fff58f8
commit 6e7149061c
19 changed files with 713 additions and 184 deletions

View File

@ -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;
}