VMPlainDatagramSocketImpl.receive effectively truncates messages to the length of the first message received with a given DatagramPacket object.
VMPlainDatagramSocketImpl.receive calls nativeReceive with incorrect length argument, namely the return value of DatagramPacket.getLength, which is not necessarily the length of the datagram packet buffer. DatagramPacket.getLength returns the instance variable length, which is modified by DatagramPacket.setData (i.e. this.length can be modified to be something other than the size of the buffer; that is the case if some data has been received already). I have determined empirically (by running the same code with Sun's implementation and with Classpath) that Sun's Java implementation DOES NOT ACT THE SAME AS CLASSPATH in this respect. DatagramSocket.receive can receive bytes up to the size of the datagram packet buffer; it is not limited by the size of a previously received message. VMPlainDatagramSocketImpl.receive should call nativeReceive so that the entire datagram packet buffer is available to receive data. I believe packet.getData().length - packet.getOffset() is the correct quantity, not getLength(). However I see that there has been some previous hacking on this. I wonder why that is. The commit message for the following change says only "Use packet.getLength()." http://cvs.savannah.gnu.org/viewcvs/classpath/vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java?root=classpath&r1=1.1&r2=1.2 ------------ begin diff ------------ nativeReceive(socket, packet.getData(), packet.getOffset(), - packet.getData().length - packet.getOffset(), + packet.getLength(), receiveFromAddress, receiveFromPort, receivedLength); ------------- end diff ------------- -- Summary: VMPlainDatagramSocketImpl.receive truncates messages to the length of the first message received Product: classpath Version: 0.90 Status: UNCONFIRMED Severity: normal Priority: P3 Component: classpath AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: robert dot dodier at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31882 _______________________________________________ Bug-classpath mailing list [EMAIL PROTECTED] http://lists.gnu.org/mailman/listinfo/bug-classpath