DatagramSocket GetPort() Example

Returns the port for this socket.


DatagramSocketclass GetPort() method example. This example shows you how to use GetPort() method.This metho Returns the port for this socket.

Here is the code:-
/**
 * @Program that Returns the port for this socket.
 * GetPort.java 
 * Author:-RoseIndia Team
 * Date:-20-jun-2008
 */
import java.net.*;
public class GetPort {
public static void main(String[] argsthrows Exception {
  DatagramSocket ds = new DatagramSocket(8080);
  ds.connect(new InetSocketAddress(9090));
  System.out.println("The port for this socket: "+ds.getPort());
    }
}

Output of the program:-
 The port for this socket: 9090

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

HOME | COPYRIGHT | CONTACT US