News:

MyKidsDiary.in :: Capture your kids magical moment and create your Online Private Diary for your kids

Main Menu

InetSocketAddress getPort Example

Started by VelMurugan, Dec 30, 2008, 11:43 PM

Previous topic - Next topic

VelMurugan

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[] args) throws 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

Source : codingdiary