ServerSocket ToString() Example
Returns the implementation address and implementation port of this socket as a String.
ServerSocketclass ToString() method example. This example shows you how to use ToString() method.This method Returns the implementation address and implementation port of this socket as a String.
Here is the code:-
/**
* @Program that Returns the implementation address and implementation port of
* this socket as a String.
* ToString.java
* Author:-RoseIndia Team
* Date:-21-jun-2008
*/
import java.net.*;
public class ToString {
public static void main(String[] args) throws Exception {
InetAddress i = InetAddress.getByName("girish-desktop");
ServerSocket ss = new ServerSocket(8080, 1, i);
System.out.println("Implementation address and implementation port: "
+ss.toString());
}
} |
Output of the program:-
| Implementation address and implementation port: ServerSocket[addr=girish-desktop/127.0.1.1,port=0,localport=8080] |
|