SCTP not work under openjdk7?
黄文辉
huanghwh at gmail.com
Mon Sep 27 08:01:58 UTC 2010
2010/9/26 黄文辉 <huanghwh at gmail.com>
> hi,
> I try to use SCTP under FreeBSD8.1+openjdk7, It seems not work.
> I use sample code from http://blogs.sun.com/chegar/entry/sctp_in_java:
>
> %/usr/local/openjdk7/bin/java -version
> openjdk version "1.7.0"
> OpenJDK Runtime Environment (build 1.7.0-root_2010_07_12_16_38-b00)
> OpenJDK 64-Bit Server VM (build 19.0-b03, mixed mode)
>
> %/usr/local/openjdk7/bin/java DaytimeServer
> Exception in thread "main" java.lang.AssertionError: Unknown event type
> at sun.nio.ch.SctpPeerAddrChange.<init>(SctpPeerAddrChange.java:75)
> at sun.nio.ch.SctpChannelImpl.receive0(Native Method)
> at
> sun.nio.ch.SctpChannelImpl.receiveIntoNativeBuffer(SctpChannelImpl.java:849)
> at sun.nio.ch.SctpChannelImpl.receive(SctpChannelImpl.java:825)
> at sun.nio.ch.SctpChannelImpl.receive(SctpChannelImpl.java:768)
> at sun.nio.ch.SctpChannelImpl.<init>(SctpChannelImpl.java:163)
> at sun.nio.ch.SctpChannelImpl.<init>(SctpChannelImpl.java:141)
> at
> sun.nio.ch.SctpServerChannelImpl.accept(SctpServerChannelImpl.java:241)
> at DaytimeServer.main(DaytimeServer.java:35)
>
>
> %/usr/local/openjdk7/bin/java DaytimeClient
> New association setup with 10 outbound streams, and 10 inbound streams.
> Exception in thread "main" java.net.SocketException: Connection reset by
> peer
> at sun.nio.ch.SctpChannelImpl.receive0(Native Method)
> at
> sun.nio.ch.SctpChannelImpl.receiveIntoNativeBuffer(SctpChannelImpl.java:849)
> at sun.nio.ch.SctpChannelImpl.receive(SctpChannelImpl.java:825)
> at sun.nio.ch.SctpChannelImpl.receive(SctpChannelImpl.java:768)
> at sun.nio.ch.SctpChannelImpl.receive(SctpChannelImpl.java:730)
> at DaytimeClient.main(DaytimeClient.java:35)
>
>
> anyone have this problem?
>
> --hwh
>
>
> This patch make sctp works, and pass most of test case in
"jdk/test/com/sun/nio/sctp"
tp# diff -u SctpChannelImpl.c.orig SctpChannelImpl.c
--- SctpChannelImpl.c.orig 2010-09-26 20:05:25.978142798 +0800
+++ SctpChannelImpl.c 2010-09-27 15:29:01.524449940 +0800
@@ -548,8 +548,11 @@
/* Set up the msghdr structure for sending */
memset(msg, 0, sizeof (*msg));
memset(cbuf, 0, cbuf_size);
- msg->msg_name = &sa;
- msg->msg_namelen = sa_len;
+ /* FreeBSD have to make msg->msg_name = NULL */
+ if(sa_len != 0){
+ msg->msg_name = &sa;
+ msg->msg_namelen = sa_len;
+ }
iov->iov_base = addr;
iov->iov_len = length;
msg->msg_iov = iov;
diff -u SctpNet.c.orig SctpNet.c
--- SctpNet.c.orig 2010-09-26 20:05:13.455803096 +0800
+++ SctpNet.c 2010-09-27 15:23:12.176899650 +0800
@@ -191,7 +191,9 @@
memset(&event, 0, sizeof(event));
event.sctp_data_io_event = 1;
event.sctp_association_event = 1;
- event.sctp_address_event = 1;
+ /* In oneToOne case, do not subscription sctp_address_event. */
+ if(!oneToOne)
+ event.sctp_address_event = 1;
event.sctp_send_failure_event = 1;
//event.sctp_peer_error_event = 1;
event.sctp_shutdown_event = 1;
More information about the freebsd-java
mailing list