Example usage for java.net Socket getTrafficClass

List of usage examples for java.net Socket getTrafficClass

Introduction

In this page you can find the example usage for java.net Socket getTrafficClass.

Prototype

public int getTrafficClass() throws SocketException 

Source Link

Document

Gets traffic class or type-of-service in the IP header for packets sent from this Socket

As the underlying network implementation may ignore the traffic class or type-of-service set using #setTrafficClass(int) this method may return a different value than was previously set using the #setTrafficClass(int) method on this Socket.

Usage

From source file:Main.java

License:asdf

public static void main(String args[]) throws Exception {
    Socket s = new Socket("internic.net", 43);
    InputStream in = s.getInputStream();
    OutputStream out = s.getOutputStream();
    String str = "asdfasdfasdf\n";
    byte buf[] = str.getBytes();
    out.write(buf);/*w  ww . j a  v  a2s.com*/
    int c;
    while ((c = in.read()) != -1) {
        System.out.print((char) c);
    }

    s.setTrafficClass(1);
    System.out.println(s.getTrafficClass());

    s.close();
}