From owner-freebsd-java@FreeBSD.ORG Mon Feb 1 00:01:41 2010 Return-Path: Delivered-To: freebsd-java@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BB4EC1065672 for ; Mon, 1 Feb 2010 00:01:41 +0000 (UTC) (envelope-from jlin@maxiscale.com) Received: from server505.appriver.com (server505b.appriver.com [98.129.35.5]) by mx1.freebsd.org (Postfix) with ESMTP id 7C9078FC0C for ; Mon, 1 Feb 2010 00:01:41 +0000 (UTC) X-Policy: GLOBAL - maxiscale.com X-Primary: jlin@maxiscale.com X-Note: This Email was scanned by AppRiver SecureTide X-ALLOW: jlin@maxiscale.com ALLOWED X-Virus-Scan: V- X-Note: Spam Tests Failed: X-Country-Path: UNITED STATES->UNITED STATES->UNITED STATES X-Note-Sending-IP: 98.129.23.14 X-Note-Reverse-DNS: ht01.exg5.exghost.com X-Note-WHTLIST: jlin@maxiscale.com X-Note: User Rule Hits: X-Note: Global Rule Hits: G169 G170 G171 G172 G176 G177 G188 G275 X-Note: Encrypt Rule Hits: X-Note: Mail Class: ALLOWEDSENDER X-Note: Headers Injected Received: from [98.129.23.14] (HELO ht01.exg5.exghost.com) by server505.appriver.com (CommuniGate Pro SMTP 5.2.14) with ESMTPS id 21865594 for freebsd-java@freebsd.org; Sun, 31 Jan 2010 18:01:43 -0600 Received: from MBX01.exg5.exghost.com ([169.254.1.90]) by ht01.exg5.exghost.com ([98.129.23.14]) with mapi; Sun, 31 Jan 2010 18:01:40 -0600 From: Joe Lin To: "freebsd-java@freebsd.org" Date: Sun, 31 Jan 2010 18:01:38 -0600 Thread-Topic: DatagramCahnnel scatter/gather problem on diablo 1.6.0_07-b02 Thread-Index: Acqi0boCP8kI5D2BQWGDTUgtRnkJuQ== Message-ID: <8B6860326495B2438DCBEA74AA981C7A78B220E0@MBX01.exg5.exghost.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: DatagramCahnnel scatter/gather problem on diablo 1.6.0_07-b02 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Feb 2010 00:01:41 -0000 Hi I wrote a sample program trying to use DatagramChannel.write(ByteBuffer[= ] bufs). The exact same code works on Windows and Linux. But it fails on th= e Diablo VM under FreeBSD 7.0 64 bit. The exception: Exception in thread "main" java.io.IOException: Invalid argument at sun.nio.ch.DatagramDispatcher.writev0(Native Method) at sun.nio.ch.DatagramDispatcher.writev(DatagramDispatcher.java:37) at sun.nio.ch.IOUtil.write(IOUtil.java:164) at sun.nio.ch.DatagramChannelImpl.write0(DatagramChannelImpl.java:4= 14) at sun.nio.ch.DatagramChannelImpl.write(DatagramChannelImpl.java:43= 1) at java.nio.channels.DatagramChannel.write(DatagramChannel.java:418= ) at coco.McastSender.main(McastSender.java:68). Following is the test program. Thanks for any help: public class McastSender { public static void main(String[] args) throws IOException { DatagramChannel channel =3D DatagramChannel.open(); DatagramSocket socket =3D channel.socket(); System.out.println("channel:" + channel + ", socket:" + socket); byte[] buf =3D new byte[1024]; DatagramPacket packet =3D new DatagramPacket(buf, buf.length); BufferedReader reader =3D new BufferedReader(new InputStreamReader(= System.in)); InetAddress address =3D InetAddress.getByName(args[0]); while ( true ) { System.out.println("waiting..."); String line =3D reader.readLine(); channel.connect(new InetSocketAddress(address, 9998)); if ( channel.isConnected() ) System.out.println("channel is connected"); else System.out.println("channel is not connected"); packet.setData("Hello".getBytes()); ByteBuffer[] bufs =3D new ByteBuffer[2]; bufs[0] =3D ByteBuffer.allocate(64); bufs[0].put("Hello".getBytes()); bufs[0].flip(); bufs[1] =3D ByteBuffer.allocate(64); bufs[1].put("World".getBytes()); bufs[1].flip(); channel.write(bufs); System.out.println("sent to " + address); channel.disconnect(); } } }