Online Java Compiler By
JavaTpoint.com
import java.io.IOException; import java.net.*; public class JavaSocketSetTcpNoDelayExample1 { public static void main(String[] args) throws IOException { //calling the constructor of the socket class Socket socket = new Socket(); //enabling the SO_TIMEOUT option boolean on=true; //setTcpNoDelay() method enables or disables the SO_TIMEOUT option socket.setTcpNoDelay(on); //getTcpNoDelay() returns the setting for SO_TIMEOUT option System.out.println("SO_TIMEOUT option is enabled: "+socket.getTcpNoDelay()); } }
Output