ServerSocket GetReuseAddress() Example
Tests if SO_REUSEADDR is enabled.
ServerSocketclass GetReuseAddress() method example. This example shows you how to use GetReuseAddress() method.This method Tests if SO_REUSEADDR is enabled.
Here is the code:-
/**
* @Program that Tests if SO_REUSEADDR is enabled.
* GetReuseAddress.java
* Author:-RoseIndia Team
* Date:-21-jun-2008
*/
import java.net.*;
public class GetReuseAddress {
public static void main(String[] args) throws Exception {
InetAddress i = InetAddress.getByName("girish-desktop");
ServerSocket ss = new ServerSocket(8080, 1, i);
//Tests if SO_REUSEADDR is enabled.
System.out.println("SO_REUSEADDR is enabled: " + ss.getReuseAddress());
}
} |
Output of the program:-
| SO_REUSEADDR is enabled: true |
|