View Full Version : Non-blocking Java Network IO
Josh Campbell
03-15-2003, 11:31 PM
I am writing some networking code for an application. I setup a socket, then use its input and output streams to send and recieve messages from a server. The I am having is that whenever I read from the socket's input stream, it blocks (stops the program from continuing while it waits for input). In my application, messages must be able to be sent without delay but they cannot because the inputstream is still trying to read in information. Is there anyway around this?
codefox
03-16-2003, 11:26 AM
I'm not sure about the type of input stream you are using. If you are using ByteArrayInputStream, everytime you are about to read find out the number of bytes available for read without blocking using the available() method.
Josh Campbell
03-16-2003, 02:53 PM
I am sending serialized objects using ObjectOutputStream and ObjectInputStream to deserialize.
Spookster
03-16-2003, 06:48 PM
I had an programming assignment just like that in college. Can't remember the details of what I used though.
vBulletin® v3.8.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.