import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;

public class SetTrafficClassTest {

    public static void main(String[] args) throws IOException {
        if (args.length != 3) {
            System.err.println("Arguments: <host> <port> <ip_tos>");
            return;
        }

        Socket socket = new Socket(args[0], Integer.parseInt(args[1]));
        socket.setTcpNoDelay(true);
        OutputStream os = socket.getOutputStream();
        byte[] bytes = new byte[] {1};
        int tc = Integer.parseInt(args[2]);
        socket.setTrafficClass(tc);
        os.write(bytes);
        System.out.println("Set Traffic class to " + tc + ", got " + socket.getTrafficClass());
        os.flush();
        os.close();
        socket.close();
    }

}