Socket setTrafficClass Example
Socket class setTrafficClass example. This example shows you how to use setTrafficClass method.
Socket class setTrafficClass example. public void setTrafficClass(int tc) throws SocketException Sets traffic class or type-of-service octet in the IP header for packets sent from this Socket. As the underlying network implementation may ignore this value applications should consider it a hint.
Here is the code
/*
* @ # SetTcpNoDelay.java
* A class repersenting use to setTcpNoDelay method
* of Socket class in java.net package
* version 23 June 2008
* author Rose India
*/
import java.net.*;
public class SetTrafficClass {
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("Traffic class " + socket.getTrafficClass());
socket.setTrafficClass(10);
System.out.println("Traffic class " + socket.getTrafficClass());
}
} |
Output
Traffic class 0
Traffic class 10 |
|