Java Socket.setSoLinger(boolean on, int linger)
Syntax
Socket.setSoLinger(boolean on, int linger) has the following syntax.
public void setSoLinger(boolean on, int linger) throws SocketException
Example
In the following code shows how to use Socket.setSoLinger(boolean on, int linger) method.
import java.net.Socket;
//ww w . ja v a2 s .c om
public class Main {
public static void main(String[] args) throws Exception {
Socket client = new Socket("google.com", 80);
client.setSoLinger(true,1000);
System.out.println(client.getSoLinger());
client.close();
}
}