Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Networking - Connected UDP channels? DatagramChannel.connect(...) Linux vs Windows  RSS feed

 
Nathan Levi
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Dukes!

Question:

Can someone please confirm that it is in fact possible to use java nio DatagramChannel in connected mode on Windows on a UDP server side, using non-blocking channels + select(), with multiple UDP clients?

I have code running on Linux as expected, but on Windows it is just bizarre;

It seems the bottom line question is:

Situation:
1) imagine you have 2 DatagramChannel s;
2) both channels are bound to the same localAddress;
3) both have socket.setReuseAddress(true);
4) first DatagramChannel is CONNECTED via channel.connect( remoteAddress );
5) second DatagramChannel is NOT connected;
6) now UDP packets start to arrive from the remoteAddress;
7) what happens? which channel will receive the packet, if at all? how select() will react? etc?

My experience is like this:

Linux answer:
a) first channel, that is, CONNECTED channel - will receive the packet and will activate select() with key.isReadble() for all traffic coming from the remoteAddress;
b) all other traffic NOT coming from the remoteAddress (that is, from NOT connected senders) will be received by the second channel, and it will also activate select() and key.isReadble() appropriately;

Windows answer:
random bizarre patterns; namely:
1) sometimes first channel receives the packet
2) sometimes second channel receives the packet
3) sometimes both channel appear to hang and do not respond to any kinds of packets - coming from either remoteAddress or otherwise;

Windows workaround:
of course, one can go back to NON connected channels, but then you can really have only SINGLE DatagramChannel on the server, servicing multiple clients, which is not the NIO way.

NOTE:
I tried this on both JDK6 and JDK7, on multiple Linux flavors as well as Windows XP, 2000 and 2003; nio on Linux consitently works; nio on Windows - consistently NOT. Also, I tried numerous permutations (about 7 different nio patterns) in the way select() / register() / interestOps() are managed; result is all the same, Linux works, Windows does not; I am at the point where I will need to try this code in C# to see if this is java or Windows problem; and I hope your answer can save me form this

Any answer or experience you have would be greatly appreciated;

Thank you very much for your help;

The End.
 
Nathan Levi
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Experts! Anyone, please?

BTW: here I got some answers:

http://forums.sun.com/thread.jspa?messageID=10676251

Thank you.

Nathan.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!