Date: Tue, 10 Sep 2002 12:13:28 -0700 From: Zachary Pincus <zpincus@stanford.edu> To: freebsd-java@freebsd.org Subject: UDP Broadcast Failure: bug returns in JDK 1.3.1 patchlevel 7 Message-ID: <63403012-C4F1-11D6-B550-000502AD507F@stanford.edu>
next in thread | raw e-mail | index | archive | help
Hello, I seem to have run across a problem with UDP broadcast in the JDK1.3.1-7. It doesn't appear to be a known issue, so here's what I have found out. Problem Summary --------------- Running the patchlevel 7 JDK 1.3.1 on FreeBSD 4.6, any attempts to send a datagram to the broadcast address fail with a "Permission Denied" IOException. Also, this error also occurs with a patchlevel 6 JDK 1.3.1 -- this problem was *not* introduced by the 7th patchset. I don't know about previous patchlevels. Problem History --------------- This error cropped up in JDK 1.8.1 (freebsd-java mailing list posting: http://www.geocrawler.com/archives/3/162/1998/4/0/808473/ ) but was repaired with a small bugfix ( http://www.geocrawler.com/archives/3/162/1999/6/0/2228696/ ). This problem with JDK 1.3.1 was alluded to early last month by Michael Allen, the jCIFS maintainer ( http://www.geocrawler.com/lists/3/FreeBSD/162/0/9237607/ ). There does not appear to have been any followup on this issue, nor was it confirmed until now, I think. (jCIFS is a java implementation of SMB/CIFS client libraries which depends on UDP broadcast for certain functionality.) Problem Regression ------------------ Test Code: TestDatagram.java (adapted from Mike Allen's code): // usage: java TestDatagram broadcast-address destination-port import java.net.*; public class TestDatagram { public static void main( String[] argv ) throws Exception { String broadcastAddress = argv[0]; int destPort = Integer.parseInt(argv[1]); DatagramPacket packet = new DatagramPacket( "hello, world".getBytes(), 12, InetAddress.getByName(broadcastAddress), destPort ); DatagramSocket socket = new DatagramSocket(); socket.send( packet ); System.out.println("Sent"); } } Code Output (compiled with javac from JDK 1.8.1, results unchanged by other compiler versions): jefferson:~>/usr/local/jdk1.1.8/bin/java TestDatagram 192.168.0.255 137 Sent jefferson:~>/usr/local/linux-sun-jdk1.3.1/bin/java TestDatagram 192.168.0.255 137 Sent jefferson:~>/usr/local/jdk1.3.1/bin/java TestDatagram 192.168.0.255 137 Exception in thread "main" java.io.IOException: Permission denied at java.net.PlainDatagramSocketImpl.send(Native Method) at java.net.DatagramSocket.send(DatagramSocket.java:321) at TestDatagram.main(TestDatagram.java:12) These results are independent of the destination port. Setting that above 1024 doesn't change anything (not that it should...). And yes, 192.168.0.255 is the proper broadcast address: jefferson:~>ifconfig fxp0 inet fxp0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 inet 192.168.0.254 netmask 0xffffff00 broadcast 192.168.0.255 Hope this helps, Zach Pincus Program in Biomedical Informatics Stanford University --------------------------------- zpincus_at_stanford_dot_edu To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?63403012-C4F1-11D6-B550-000502AD507F>