1) Here is UDP rfc: http://www.ietf.org/rfc/rfc768.txt. It's clearly says that: "Length is the length in octets of this user datagram including this header and the data. (This means the minimum value of the length is eight.)", i.e. allows packets with empty data part. 2) JAVA API spec for UDP says nothing about empty data buffers, it only prohibits using null data buffers and negative or greater that the packet's data buffer lengths. 3) I found no info in Windows API forbidding sending UDP packets with zero data length.
I'm wondering why these failures were not detected on Windows before... Perhaps i have a "special" version of WinXP :-) or it requires some additional configuring. Regards, Mikhail On 2/19/07, Alexey Petrenko <[EMAIL PROTECTED]> wrote:
> Yes. OK. Is it OK to send zero sized UDP packet according to UDP spec and Win32 documentation? SY, Alexey > On 2/19/07, Alexey Petrenko <[EMAIL PROTECTED]> wrote: > > > > I did not quite understand. > > Does your test fail on RI on Win? > > > > SY, Alexey > > > > 2007/2/19, Mikhail Markov <[EMAIL PROTECTED]>: > > > Hi! > > > > > > I found a difference between sending datagram packets with zero length > > on > > > Windows and Linux: > > > The test below passes both on RI and Harmony on Linux, but fails on my > > > WinXP: > > > RI: Exception in thread "main" java.net.SocketException: The message is > > > larger than the maximum supported by the underlying transport: Datagram > > send > > > failed > > > at java.net.PlainDatagramSocketImpl.send(Native Method) > > > at java.net.DatagramSocket.send(DatagramSocket.java:612) > > > at Test.main(Test.java:9) > > > > > > Harmony: Exception in thread "main" java.net.SocketException: (10040) A > > > message sent on a datagram socket was larger than the internal message > > > buffer or some other network limit, or the buffer used to receive a > > datagram > > > into was smaller than the datagram itself. > > > at > > org.apache.harmony.luni.platform.OSNetworkSystem.sendDatagramImpl (Native > > > Method) > > > at org.apache.harmony.luni.platform.OSNetworkSystem.sendDatagram( > > > OSNetworkSystem.java:155) > > > at org.apache.harmony.luni.net.PlainDatagramSocketImpl.send( > > > PlainDatagramSocketImpl.java:275) > > > at java.net.DatagramSocket.send(DatagramSocket.java:450) > > > at Test.main(Test.java:9) > > > > > > Due to this I have 9 constantly failed testcases from > > DatagramChannelTest > > > (nio module): > > > testSend_NoServerTwice(), > > > testSend_NoServerNonBlockingTwice(), > > > testReceiveSend_Block_Empty(), > > > testReceiveSend_NonBlock_Empty(), > > > testReceiveSend_Block_Empty_S2C(), > > > testReceiveSend_NonBlock_Empty_S2C(), > > > testReceiveSend_Block_Empty_C2S(), > > > testReceiveSend_NonBlock_Empty_C2S(), > > > testReceiveSend_Empty_S2S() > > > trying to send empty datagrams. > > > > > > I've filed the appropriate JIRA > > > https://issues.apache.org/jira/browse/HARMONY-3185, and even provided > > the > > > patch (which seems not correct :-). > > > > > > What should we do with these tests? Perhaps it makes sense to rework > > them to > > > avoid sending empty datagrams? > > > > > > Regards, > > > Mikhail > > > > > > Here is the test: > > > import java.net.DatagramSocket; > > > import java.net.DatagramPacket; > > > import java.net.InetAddress; > > > > > > public class Test { > > > public static void main(String[] args) throws Exception { > > > DatagramSocket ds = new DatagramSocket(); > > > DatagramPacket dp = new DatagramPacket(new byte[0], 0, > > > InetAddress.getLocalHost(), 5555); > > > ds.send(dp); > > > } > > > } > > > > > >
