Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4709474
Votes 0
Synopsis getTrafficClass() and setTrafficClass() is not behaving properly in linux
Category java:classes_net
Reported Against hopper
Release Fixed
State 11-Closed, Not a Defect, bug
Priority: 4-Low
Related Bugs
Submit Date 28-JUN-2002
Description
Build : Hopper build 15
Platform : Linux 7.1 and 7.2
Harware : pentium

getTrafficClass() and  setTrafficClass() is not behaving properly in linux. According to the javadoc the integer passed to setTrafficClass can be between 0 and 255 but it is not taking more than 159. Also if the setTrafficClass is set to 159 or any other number close to but less than this number  then the getTrafficClass is not showing the set number. I have checked on 2 linux machines and both are giving the same results.
I am not sure if this has to do anything with the linux setup
Any number above from 160 to 255 it is giving
java.net.SocketException: Operation not permitted

-----------------

import java.net.*;
import java.io.*;
public class loopback {
 public static void main(String args[]) {

 try
 {
 Socket sock = new Socket();
 InetSocketAddress loc1 =  (InetSocketAddress)sock.getLocalSocketAddress();
 sock.setTrafficClass(160);

 if(sock.getTrafficClass() == 160){
     System.out.println("TestgetTrafficClass():correct TrafficClass set for socket test : Pass");
          }else{
          System.out.println("TestgetTrafficClass:correct TrafficClass set for socket test  : Fail");
          System.out.println(sock.getTrafficClass());
          }

 }
 catch(SocketException exp) {
 System.out.println(exp);
 }
 catch(IOException exp) {
 System.out.println(exp);
 }

 }
 }

----------------
Work Around
N/A
Evaluation
On Linux you can't set IP_TOS to >= 0xa0 unless you are root.  The
question is should setTrafficClass throw an exception (as it does now),
fail silently, or attempt to set IP_TOS to a "reasonable" value if the
supplied ToS is not permitted. As setTrafficClass(int) is specified as
a hint then failing silently or using a "reasonable" alternative
value would be valid approaches. Will examine for mantis.

  xxxxx@xxxxx   2002-06-28

The Java spec says:

"As the underlying network implementation may ignore
     this value applications should consider it a hint. 

Setting bits in the precedence field may result in a SocketException
     indicating that the operation is not permitted."

So will close as "not a bug".

  xxxxx@xxxxx   2002-10-01
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang