Home > Archive > Java Help > December 2004 > setTrafficClass question
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
setTrafficClass question
|
|
| dennylee60@gmail.com 2004-12-22, 9:14 pm |
| Hello,
I am trying to use the setTrafficClass function but when I look at the
packets in a sniffer, the TOS is set at 0. What am I doing wrong?
Below is the test code I am playinig with. Thanks.
public class TOSMulticast {
public static void main(String[] args) {
byte[] outbuf = new byte[1024];
int port = 1234;
try
{
InetAddress group = InetAddress.getByName("228.5.6.7");
DatagramSocket s = new DatagramSocket();
s.connect(group, 5000);
s.setSoTimeout(100);
s.setTrafficClass(100);
for(int i = 0; i < 1000; i++)
{
DatagramPacket p = new DatagramPacket(outbuf, outbuf.length);
s.send(p);
}
}
catch (SocketException e)
{
System.out.println(e.toString());
}
}
| |
| Michael Wong 2004-12-23, 4:08 pm |
| Check the documentation for setTrafficClass:
http://java.sun.com/j2se/1.4.2/docs...setTrafficClass(int)
It's clearly documented that this value may be ignored by the underlying
implementation. Also, you may want to try calling setTrafficClass on the
socket before you connect. Though this shouldn't be the problem, you never
know.
<dennylee60@gmail.com> wrote in message
news:1103742475.058377.109130@f14g2000cwb.googlegroups.com...
> Hello,
> I am trying to use the setTrafficClass function but when I look at the
> packets in a sniffer, the TOS is set at 0. What am I doing wrong?
> Below is the test code I am playinig with. Thanks.
>
> public class TOSMulticast {
>
> public static void main(String[] args) {
>
>
> byte[] outbuf = new byte[1024];
> int port = 1234;
>
>
> try
> {
> InetAddress group = InetAddress.getByName("228.5.6.7");
> DatagramSocket s = new DatagramSocket();
> s.connect(group, 5000);
> s.setSoTimeout(100);
> s.setTrafficClass(100);
> for(int i = 0; i < 1000; i++)
> {
> DatagramPacket p = new DatagramPacket(outbuf, outbuf.length);
> s.send(p);
> }
>
> }
> catch (SocketException e)
> {
> System.out.println(e.toString());
> }
>
> }
>
|
|
|
|
|