DatagramSocket SetTrafficClass() Example

Sets traffic class or type-of-service octet in the IP datagram header for datagrams sent from this DatagramSocket


DatagramSocketclass SetTrafficClass() method example. This example shows you how to use SetTrafficClass() method.This method Sets traffic class or type-of-service octet in the IP datagram header for datagrams sent from this DatagramSocket

Here is the code:-

/**
 * @Program that Sets traffic class or type-of-service in the IP datagram header
 * for packets sent from this DatagramSocket. 
 * SetTrafficClass.java 
 * Author:-RoseIndia Team
 * Date:-20-jun-2008
 */
import java.net.*;

public class SetTrafficClass {

    public static void main(String[] argsthrows Exception {
        DatagramSocket ds = new DatagramSocket();
        ds.connect(new InetSocketAddress(9090));
        System.out.println("The traffic class: " + ds.getTrafficClass());
        //Sets traffic class or type-of-service in the IP datagram header for
        //packets sent
        ds.setTrafficClass(254);
        System.out.println("The traffic class: " + ds.getTrafficClass());
              
    }
}

Output of the program:-
 The traffic class: 0
The traffic class: 254

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US