Original Post
🔒 Locked
Non-blocking sockets in Java
Advertisement
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/
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/
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..
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.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement