Online Java Compiler By
JavaTpoint.com
import java.io.IOException; import java.net.*; public class JavaSocketSetTrafficClassExample3 { public static void main(String[] args) throws IOException { //calling the constructor of the socket class Socket socket = new Socket(); //closing the socket socket.close(); //integer value for the bitset. int tc=98; //setTrafficClass() sets the traffic class or type-of-service in the IP header for packets sent from the specified socket //it will throw an error, as the socket is already closed socket.setTrafficClass(tc); //getTcpNoDelay() returns the setting for SO_TIMEOUT option System.out.println("Traffic class: "+socket.getTrafficClass()); } }
Output