Online Java Compiler By
JavaTpoint.com
import java.io.IOException; import java.net.*; public class JavaSocketSetSoLingerExample3 { public static void main(String[] args) throws IOException { //calling the constructor of the socket class Socket socket = new Socket(); //disabling the SO_LINGER option boolean on=true; //setting the integer value for timeout //the timeout value should be greater or equal to 0 int timeout=-10; socket.setSoLinger(on,timeout); //getSoLinger() method returns the setting if the SO_Linger option is set System.out.println("Send Buffer size: "+socket.getSoLinger()); } }
Output