Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ProtocolFamily;
import java.net.Socket;
import java.net.SocketAddress;
import java.net.SocketOption;
import java.net.StandardProtocolFamily;
import java.net.StandardSocketOptions;
import java.net.UnknownHostException;
import java.nio.channels.CancelledKeyException;
Expand Down Expand Up @@ -346,7 +348,7 @@ private void processPendingConnectionRequests() {
if (!sessionRequest.isCancelled()) {
final SocketChannel socketChannel;
try {
socketChannel = SocketChannel.open();
socketChannel = openSocketFor(sessionRequest.remoteAddress);
} catch (final IOException ex) {
sessionRequest.failed(ex);
return;
Expand All @@ -361,6 +363,18 @@ private void processPendingConnectionRequests() {
}
}

private static SocketChannel openSocketFor(final SocketAddress remoteAddress) throws IOException {
if (remoteAddress instanceof InetSocketAddress) {
return SocketChannel.open();
}
try {
return (SocketChannel) SocketChannel.class.getMethod("open", ProtocolFamily.class)
.invoke(null, StandardProtocolFamily.valueOf("UNIX"));
} catch (final ReflectiveOperationException e) {
throw new UnsupportedOperationException("UNIX-family socket channels not supported", e);
}
}

private void processConnectionRequest(final SocketChannel socketChannel, final IOSessionRequest sessionRequest) throws IOException {
socketChannel.configureBlocking(false);
prepareSocket(socketChannel);
Expand Down