Socket.setSoLinger(boolean on, int linger) has the following syntax.
public void setSoLinger(boolean on, int linger) throws SocketException
In the following code shows how to use Socket.setSoLinger(boolean on, int linger) method.
import java.net.Socket; //from w w w . j ava 2 s . co m 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(); } }
The code above generates the following result.