Socket getReuseAddress Example

Socket class getReuseAddress example. This example shows you how to use getReuseAddress method.


Socket class getReuseAddress example. public boolean getReuseAddress() throws SocketException Tests if SO_REUSEADDR is enabled.

Here is the code
/*
 * @ # GetReuseAddress.java
 * A class repersenting use to
GetReuseAddress method 
 * of NumberFormat class in java.text package
 * version 17 June 2008
 * author Rose India 
 */

import java.net.*;

public class GetReuseAddress {

    public static void main(String args[]) throws Exception {

        Socket socket = new Socket();

        //Connects this socket to the server.
        socket.connect(new InetSocketAddress("192.168.10.211"8080));

        if (!socket.getReuseAddress()) {
            socket.setReuseAddress(true);
        }
        System.out.println("Reuse Address " + socket.getReuseAddress());

        //close socket
        socket.close();
    }
}

Output
Reuse Address true

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US