Socket(InetAddress address, int port) constructor from Socket has the following syntax.
public Socket(InetAddress address, int port) throws IOException
In the following code shows how to use Socket.Socket(InetAddress address, int port) constructor.
//from w w w.ja va2 s. com import java.net.InetAddress; import java.net.Socket; public class Main { public static void main(String[] argv) throws Exception { InetAddress addr = InetAddress.getByName("java.sun.com"); int port = 80; Socket socket = new Socket(addr, port); } }