Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2002
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Non-blocking Java Network IO

    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?

  • #2
    Regular Coder
    Join Date
    Nov 2002
    Location
    India
    Posts
    159
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #3
    New Coder
    Join Date
    Jun 2002
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am sending serialized objects using ObjectOutputStream and ObjectInputStream to deserialize.

  • #4
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,273
    Thanks
    4
    Thanked 83 Times in 82 Posts
    I had an programming assignment just like that in college. Can't remember the details of what I used though.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •