previous | start | next

Other Socket Operations

Java provides a few other entertaining socket operations, apart from reading from (via getInputStream(), and writing to (via getOutputStream()), the connected socket:
getInetAddress()
 
Returns the IP address of the system that this socket is connected to.
 
getPort()
 
Returns the port number that the socket is connected to on the remote system.
 
getLocalPort()
 
Returns the port number on the local system. For a client socket, this will be the random (?) port number allocated when the initial TCP connection was established.

 


previous | start | next