Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Mar 2003 03:28:34 +0100
From:      Stefan Farfeleder <stefan@fafoe.dyndns.org>
To:        java@FreeBSD.org
Subject:   jdk14 MulticastSocket breakage
Message-ID:  <20030309022834.GA585@frog.fafoe>

next in thread | raw e-mail | index | archive | help
[please CC me, thanks]

Hi,

I think I've found a bug in the java/jdk14 port.  The method
java.net.MulticastSocket.joinGroup() always fails with
"java.net.SocketException: Invalid argument" (a small program to
demonstrate this can be found at
http://stud3.tuwien.ac.at/~e0026813/FreeBSD/multicast.java ).

With ktrace I've tracked this down to:

1216 java     CALL  setsockopt(0x6,0,0x1,0xbf8e5b80,0x8)
1216 java     RET   setsockopt -1 errno 22 Invalid argument

Then I looked into the source code and found that
bsd-jdk14-patches-3.tar.gz made these changes to
j2se/src/solaris/native/java/net/PlainDatagramSocketImpl.c

-       if (JVM_SetSockOpt(fd, IPPROTO_IP, (join ? IP_ADD_MEMBERSHIP:IP_DROP_MEMBERSHIP),
+// XXXBSD: fix for BSD (re-implement with KAME ?)
+//     if (JVM_SetSockOpt(fd, IPPROTO_IP, (join ? IP_ADD_MEMBERSHIP:IP_DROP_MEMBERSHIP),
+       if (JVM_SetSockOpt(fd, IPPROTO_IP, (join ? 1 : 0),

which I do not understand.  <netinet/in.h> has 12 for IP_ADD_MEMBERSHIP
and 13 for IP_DROP_MEMBERSHIP, the 1 corresponds to IP_OPTIONS and
causes the EINVAL failure.  Reverting these changes and recompiling
jdk14 fixes the failure for me.

The patch also changes IPV6_ADD_MEMBERSHIP and IPV6_DROP_MEMBERSHIP into
1 and 0 which seems bogus too.  These constants are available on Linux
but not on FreeBSD; I think the values IPV6_JOIN_GROUP and
IPV6_LEAVE_GROUP should be used instead.

Regards,
Stefan Farfeleder

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?20030309022834.GA585>