Java - networking Socket Class Methods
ublic Socket(String host, int port, InetAddress localAddress, int localPort) throws IOException.
Connects to the specified host and port, creating a socket on the local host at the specified address and port.
String toString()
Converts this IP address to a String.
static InetAddress getByAddress(String host, byte[] addr)
Create an InetAddress based on the provided host name and IP address.
public Socket()
Creates an unconnected socket. Use the connect() method to connect this socket to a server.
static InetAddress getByName(String host)
Determines the IP address of a host, given the host's name.
String getHostName()
Gets the host name for this IP address.
static InetAddress getByAddress(byte[] addr)
Returns an InetAddress object given the raw IP address .
String getHostAddress()
Returns the IP address string in textual presentation.
static InetAddress InetAddress getLocalHost()
Returns the local host.
public Socket(InetAddress host, int port, InetAddress localAddress, int localPort) throws IOException.
This method is identical to the previous constructor, except that the host is denoted by an InetAddress object instead of a String
public Socket(InetAddress host, int port) throws IOException
This method is identical to the previous constructor, except that the host is denoted by an InetAddress object.
public Socket(String host, int prt) throws UnkownHostException, IOException.
his method attempts to connect to the specified server at the specified port. If this constructor does not throw an exception, the connection is successful and the client is connected to the server.