Java tutorial
//package com.java2s; // license that can be found in the LICENSE file. import java.io.IOException; import java.net.InetSocketAddress; import java.net.SocketAddress; import java.nio.channels.SocketChannel; public class Main { public static SocketChannel connect(int port) throws IOException { SocketAddress sa = new InetSocketAddress("127.0.0.1", port); return SocketChannel.open(sa); } }