From owner-freebsd-java Tue Sep 10 12:13:43 2002 Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 934D437B400 for ; Tue, 10 Sep 2002 12:13:38 -0700 (PDT) Received: from smtp-remote.Stanford.EDU (smtp-remote.Stanford.EDU [171.64.14.171]) by mx1.FreeBSD.org (Postfix) with ESMTP id 199C243E6A for ; Tue, 10 Sep 2002 12:13:38 -0700 (PDT) (envelope-from zpincus@stanford.edu) Received: from axlotl.local. (adsl-66.218.46.225.dslextreme.com [66.218.46.225]) by smtp-remote.Stanford.EDU (8.11.6/8.11.6) with ESMTP id g8AJDUv05892 for ; Tue, 10 Sep 2002 12:13:32 -0700 (PDT) Date: Tue, 10 Sep 2002 12:13:28 -0700 Mime-Version: 1.0 (Apple Message framework v543) Content-Type: text/plain; charset=US-ASCII; format=flowed Subject: UDP Broadcast Failure: bug returns in JDK 1.3.1 patchlevel 7 From: Zachary Pincus To: freebsd-java@freebsd.org Content-Transfer-Encoding: 7bit Message-Id: <63403012-C4F1-11D6-B550-000502AD507F@stanford.edu> X-Mailer: Apple Mail (2.543) Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org 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 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