DatagramSocket constructor of DatagramSocket class is used to create datagram socket- Java

Q.  Which constructor of DatagramSocket class is used to creates a datagram socket and binds it with the given Port Number?
- Published on 15 Jul 15

a. DatagramSocket(int port)
b. DatagramSocket(int port, InetAddress address)
c. DatagramSocket()
d. None of the above

ANSWER: DatagramSocket(int port, InetAddress address)
 

    Discussion

  • Prajakta Pandit   -Posted on 15 Dec 15

    - DatagramSocket(int port, InetAddress address) constructor of DatagramSocket class is used to create a datagram socket and binds it with the given Port Number.

    - DatagramSocket represents a connection-less socket for sending and receiving the datagram packets.

    - The DatagramSocket(int port, InetAddress address) specifies the host address.

    - The local port must be between 0 and 65535 inclusive.

Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)