Multiple choice technology programming languages

The assigned port at the server can be obtained in the client side by

  1. getLocalPort() method

  2. getActivePort() method

  3. By pinging the server

  4. By giving value 0 as port number

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The getLocalPort() method returns the local port number to which the socket is bound. On the server side, this reveals the port assigned to the ServerSocket. On the client side, it shows the ephemeral port used for the connection. Options B and D are not valid methods or approaches for port discovery.