new Socket(InetAddress address, int port) throws IOException : Socket « java.net « Java by API






new Socket(InetAddress address, int port) throws IOException

  


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

   
    
  








Related examples in the same category

1.Socket: connect(SocketAddress endpoint, int timeout) throws IOException
2.Socket: getInputStream() throws IOException
3.Socket: getLocalSocketAddress()
4.Socket: getOutputStream() throws IOException
5.Socket: getRemoteSocketAddress()
6.Socket: readUTF() and writeUTF(String str)