Java ServerSocket getLocalPort() MethodThe getLocalPort() method of ServerSocket class is used to give the port number of the server on which this socket is listening. If the socket was bound before being closed, then this method will continue to return the port number after the socket is closed. SyntaxParameter:No Parameter. Returns:The port number to which this socket is listening or -1 if the socket is not bound yet. Example 1ServerApplication: ClientApplication Example 2ServerApplication clientApplication: Output:
Next TopicJava ServerSocket
|