Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Java on Tiger and UDP



Hi Guys.  We have a problem with our application.

On Panther, you could send UDP packets > 16356 bytes from Java, and receive them without issue.

On Tiger, any UDP packets > 16356 bytes are dropped. You just never receive them.

I've included two classes Send.java and Receive.java, to demonstrate this.

Basically, you open two terminals.  In one, you do:

  java -cp . Receive

In the other:

  java -cp . Send <SIZE>

eg. java -cp . Send 16356

On Panther you can send packets up to around 64k as expected. On Tiger anything above 16356 (just under 16k) is dropped.

Does that makes sense to anyone?

We thought it was a sysctl issue, as sysctl -a shows:

net.inet.udp.maxdgram: 9216

But that is the same on Panther, and changing it via sysctl makes no difference.

Any help appreciated.

Thanks.

Jamie

------ Receive.java ------

import java.net.*;
import java.io.*;

public class Receive
{
    public static void main(String args[])
    {
    String host = "localhost";
    int port = 9999;
    InetAddress addr = null;
    try {
        addr = InetAddress.getByName(host);
    } catch (UnknownHostException uhe) { }

try {
DatagramSocket ds = new DatagramSocket(port);
DatagramPacket rec = new DatagramPacket(new byte[65530], 65530);
rec.setLength(65530);
ds.receive(rec);
String line = new String(rec.getData(), 0, rec.getLength());
System.out.println(line);
System.out.println("Received " + rec.getLength() + " bytes");
} catch (IOException ie) { }
}
}


------ Send.java ------

import java.net.*;
import java.io.*;

public class Send
{
    public static void main(String args[])
    {
    String host = "localhost";
    int port = 9999;
    int max = 1;
    if (args.length > 0) {
        try {
        max = Integer.parseInt(args[0]);
        } catch (NumberFormatException nfe) { }
    }

    InetAddress addr = null;
    try {
        addr = InetAddress.getByName(host);
    } catch (UnknownHostException uhe) { }

    try {
        DatagramSocket ds = new DatagramSocket();
        byte[] buf = new byte[max];
        for (int i = 0; i < buf.length; i++) {
        buf[i] = '.';
        }
        ds.send(new DatagramPacket(buf, buf.length, addr, port));
    } catch (IOException ie) { }
    }
}


_______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.