Socket setTcpNoDelay Example
Socket class setTcpNoDelay example. This example shows you how to use setTcpNoDelay method.
Socket class setTcpNoDelay example. public void setTcpNoDelay(boolean on) throws SocketException Enable/disable TCP_NODELAY (disable/enable Nagle's algorithm).
Here is the code
/*
* @ # SetTcpNoDelay.java
* A class repersenting use to SetTcpNoDelay method
* of NumberFormat class in java.net package
* version 17 June 2008
* author Rose India
*/
import java.net.*;
public class SetTcpNoDelay {
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.222", 8080));
System.out.println("TCP_NODELAY " + socket.getTcpNoDelay());
socket.setTcpNoDelay(true);
System.out.println("TCP_NODELAY " + socket.getTcpNoDelay());
socket.close();
}
}
|
Output
TCP_NODELAY false
TCP_NODELAY true |
|