Socket getTrafficClass Example

Socket class getTrafficClass example. This example shows you how to use getTrafficClass method.


Socket class getTrafficClass example. public int getTrafficClass() throws SocketException 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.

Here is the code
/*
 * @ # GetTrafficClass
.java
 * A class repersenting use to
getTrafficClass method 
 * of NumberFormat class in java.text package
 * version 20 June 2008
 * author Rose India 
 */

import java.net.*;

public class GetTrafficClass {

    public static void main(String args[]) throws Exception {

        Socket socket = new Socket();

        //Connects this socket to the server.
        socket.connect(new InetSocketAddress("192.168.10.211"8080));

        if (!socket.getTcpNoDelay()) {
            socket.setTcpNoDelay(true);
        }
        System.out.println("TcpNoDelay " + socket.getTcpNoDelay());

        //close socket
        socket.close();
    }
}

Output
TcpNoDelay true

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

HOME | COPYRIGHT | CONTACT US