Skip to main content
gamedev.net
🔒 Locked

Non-blocking sockets in Java

Started by xissburg Mar 6, 2009 at 7:42 PM 4 replies 1.3k views
Original Post
xissburg
xissburg
How? {Thanks}
.
superoptimo
superoptimo
If your app has shared data you will always have to use blocks.

there is another approach which minimizes the blocks, which consist on synchronizing program components with message passing. Components are objects that acts as Workers. These workers perform processing tasks then they receive messages from their input ports, and when they finish send their processed result as output messages through output ports that will be sinked by other connected workers.

More details:

http://en.wikipedia.org/wiki/Flow-based_programming

http://en.wikipedia.org/wiki/Dataflow

http://jpaulmorrison.com/fbp/

xissburg
xissburg
Quote:
Original post by Megahertz

http://lmgtfy.com/?q=non+blocking+sockets+in+java

Prolly gonna get flamed for this one.


Hey very funny.. I already tried that but none of the results really satisfied me then i'm coming here to see if anyone has something interesting to say or knows a decent article about...

And superoptimo I just need a kind of receive() function which doesn't blocks program execution, one which returns if there isn't anything new. I'm using ObjectIn/OutputStreams and i could use the available() method but i can't understand why it returns zero even when there are things to read..annoying..



.
Bob Janova
Bob Janova
I wrote a socket cover that sat in a thread (which blocked of course) and allowed you to check availability. It was a long time ago and I imagine the Java libraries now have a way to do async sockets built in. I can try to find mine if you like.
pjcast
pjcast
This is the best networking library I've found for Java: http://mina.apache.org/

Edit - I said threading at first, but meant networking :)

[Edited by - pjcast on March 7, 2009 9:16:19 AM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.