ServerSocket GetLocalPort() Example

ServerSocketclass GetLocalPort() method example. This example shows you how to use GetLocalPort() method.This method


ServerSocketclass GetLocalPort() method example. This example shows you how to use GetLocalPort() method.This method ServerSocketclass GetLocalPort() method example. This example shows you how to use GetLocalPort() method.This method

Here is the code:-

/**
 * @Program that Returns the port on which this socket is listening.
 * GetLocalPort.java 
 * Author:-RoseIndia Team
 * Date:-21-jun-2008
 */
import java.net.*;

public class GetLocalPort {

    public static void main(String[] argsthrows Exception {
        ServerSocket ss = new ServerSocket(8080);
        //Returns the port on which this socket is listening.
        System.out.println("Port on which this socket is listening: " + ss.getLocalPort());
    }
}

Output of the program:-
 Port on which this socket is listening: 8080

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

HOME | COPYRIGHT | CONTACT US