if(localHost == null) {
InetSocketAddress addr = new InetSocketAddress(InetAddress.getByName(remoteHost), remotePort);
channel = SocketChannel.open(addr);
} else {
channel = SocketChannel.open();
Socket socket = channel.socket();
socket.bind(new InetSocketAddress(InetAddress.getByName(localHost), localPort));
socket.connect(new InetSocketAddress(InetAddress.getByName(remoteHost), remotePort));
}
channel.finishConnect();
initSocket(context.getRuntime(), new ChannelDescriptor(channel, RubyIO.getNewFileno(), new ModeFlags(ModeFlags.RDWR), new FileDescriptor()));