Socket.setTrafficClass() on Mac OS X

Hi all,

I have TCP code which works fine on Linux, but fails on Mac OS X (java 1.5.0_07-87). In particular, the setTrafficClass below (the hex number is IPTOS_THROUGHPUT) throws a IOException with the following error:

upload: Invalid argument

[java] java.net.SocketException: Invalid argument

[java]at java.net.PlainSocketImpl.socketSetOption(Native Method)

[java]at java.net.PlainSocketImpl.setOption(PlainSocketImpl.java:264)

[java]at java.net.Socket.setTrafficClass(Socket.java:1211)

byte[] address = isa.getAddress().getAddress();

if (address.length == IPv4_INADDRSZ){// IPv4

s.setTrafficClass(0x08);

}

Any idea?

Thanks,

Michele

[869 byte] By [michele81a] at [2007-11-27 10:14:32]
# 1

Don't do it. IPTOS_THROUGHPUT was obsoleted in 1998 by RFC 2474. It won't do what you want unless you know that your router and all other routers on the path obey it. Obviously MacOS doesn't obey it so there you are ...

ejpa at 2007-7-28 15:33:55 > top of Java-index,Core,Core APIs...