InetSocketAddress getPort Example

InetSocketAddress class getPort example. This example shows you how to use getPort method.


InetSocketAddress class getPort example. public final int getPort() Gets the port number.

Here is the code
/*
 * @ # GetPort.java
 * A class repersenting use to
GetPort method 
 * of InetSocketAddress class in java.net package
 * version 23 June 2008
 * author Rose India 
 */

import java.net.*;

public class GetPort {

    public static void main(String[] argsthrows Exception {

        //Get local host.
        InetAddress inetAddress = InetAddress.getLocalHost();

        InetSocketAddress inetSocketAddress = new InetSocketAddress(inetAddress, 1313);

        //Gets InetAddress.
        System.out.println("port number " + inetSocketAddress.getPort());
    }
}

Output
port number 1313

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

HOME | COPYRIGHT | CONTACT US