Socket getLocalSocketAddress Example

Socket class getLocalSocketAddress example. This example shows you how to use getLocalSocketAddress method.


Socket class getLocalSocketAddress example. public SocketAddress getLocalSocketAddress() Returns the address of the endpoint this socket is bound to, or null if it is not bound yet.

Here is the code
/*
 * @ # GetLocalSocketAddress.java
 * A class repersenting use to getLocalSocketAddress method 
 * of NumberFormat class in java.text package
 * version 17 June 2008
 * author Rose India 
 */

import java.net.*;

public class GetLocalSocketAddress {

    public static void main(String args[]) throws Exception {

        Socket socket = new Socket();

        //Connects this socket to the server.
        socket.connect(new InetSocketAddress("192.168.10.80"9090));

        SocketAddress  socketAddress=socket.getLocalSocketAddress();
        
        System.out.println(socketAddress);
        
        //close socket
        socket.close();
    }
}

Output
/192.168.10.222:36136

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US