Java Socket getReuseAddress () methodThe getReuseAddress () method of Java Socket class tests whether the SO_REUSEADDR option is enabled or not. It throws SocketException if finds an error in the underlying protocol, such as a TCP error. SyntaxParameterNA ReturnThe getReuseAddress () method returns a Boolean value 'true' if the SO_REUSEADDR is enabled else it returns false. ThrowsSocketException - if an error is there in the underlying protocol, such as a TCP error. Example 1Test it NowOutput: SO_REUSEADDR option is enabled: true Example 2Test it NowOutput: SO_REUSEADDR option is enabled: false Example 3Test it NowOutput: Exception in thread "main" java.net.SocketException: Socket is closed at java.net.Socket.setReuseAddress(Socket.java:1448) at com.javaTpoint.JavaSocketGetReuseAddressExample3.main(JavaSocketGetReuseAddressExample3.java:13) Next TopicJava Socket Class |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India