Online Java Compiler By
JavaTpoint.com
import java.io.IOException; import java.net.*; public class JavaSocketGetTrafficClassExample1 { public static void main(String[] args) throws IOException { //calling the constructor of the socket class Socket socket = new Socket(); int tc=89; //sets the traffic class for this socket socket.setTrafficClass(tc); //getTrafficClass() returns the traffic class System.out.println("Traffic class: "+socket.getTrafficClass()); } }
Output