Example usage for java.net DatagramSocket getTrafficClass

List of usage examples for java.net DatagramSocket getTrafficClass

Introduction

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

Prototype

public synchronized int getTrafficClass() throws SocketException 

Source Link

Document

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

Usage

From source file:Main.java

public static void main(String args[]) {
    try {/* w  w w  . j a v  a  2 s .c  o  m*/

        InetAddress ia = InetAddress.getByName("www.java2s.com");

        DatagramSocket ds = new DatagramSocket();

        byte buffer[] = "hello".getBytes();
        DatagramPacket dp = new DatagramPacket(buffer, buffer.length, ia, 80);

        // Send the datagram packet
        ds.send(dp);

        System.out.println(ds.getTrafficClass());
    } catch (Exception e) {
        e.printStackTrace();
    }
}