Message1868

Author amak
Recipients
Date 2008-01-04.07:23:06
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
The problem is that the UDP support in the updated socket module has not been fully updated to use java.nio.

In the update of the socket module to support asynch sockets with java.nio, the creation of UDP sockets was updated to use the NIO API for creating an UDP socket, through the use of the DatagramChannel.open() method.

But the reading and writing of packets from/to the UDP socket still uses the old DatagramSocket API. Which in this case sees to cause a hang, when it appears that it shouldn't.

To illustrate the problem, I've rewritten Bob's java code, and atached it to this bug.

My version reads the command line arguments, looking for options, of which there are two.

By default, if no options are given, the code

1. Creates the UDP socket using the DatagramSocket API, which is the old java.net API.
2. Reads all messages through the DatagramSocket.receive() method.

This combination is analogous to the old jython (pre-asynch) socket module, and works as the OP expects, correctly I believe.

If the "create_nio" option is given on the command line

1. The UDP socket is created using the java.nio DatagramChannel.open() method 
2. All messages are read using the "old" java.net DatagramSocket.receive method()

This combination is analogous to the current status of the socket module, i.e. it hangs when two threads read and write on the socket at the same time.

If the "create_nio" and "read_nio" options are both given on the command line

1. The UDP socket is created using the java.nio DatagramChannel.open() method 
2. All messages are read using the "new" java.nio DatagramChannel.receive method()

This combination is analogous to the way the socket module *should* (and will) be. It uses only java.nio APIs, and exhibits the expected behaviour, i.e. it does not hang.

So the solution to this bug is to update the implementation of UDP sockets to use java.nio APIs for send and receive.

I will post an outline implementation on this bug report in a few days.

But I will not get to update the socket module, i.e. update the SVN repo, update the test suites, etc, for a week or so.

Alan.



File Added: JavaTestUDPNIO.java
History
Date User Action Args
2008-02-20 17:18:00adminlinkissue1782548 messages
2008-02-20 17:18:00admincreate