This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes Length of the Socket Input Stream to Read 'OR' End of the Socket Stream Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » I/O and Streams
Reply locked New topic
Author

Length of the Socket Input Stream to Read 'OR' End of the Socket Stream

Maheshwari Anuj
Greenhorn

Joined: May 03, 2010
Posts: 14
Hi All,

I have to read a response from a TCP Socket's Input Stream. But I dont know the number of bytes that are coming in response. There is a function called available() that gives the number of bytes available in the stream, but its not reliable, it works some time and sometime not. I also tried to read data till I found "-1" which marks the end of the stream but this is also not working beacuse I think at the server end streams are not getting closed that why I am not getting "-1". Please Help.

Regards,
Anuj Maheshwari
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

Please Use One Thread Per Question. You asked the same question here.

I'm sure Joe doesn't mind if I close this thread.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
GeeCON Prague 2014
 
subject: Length of the Socket Input Stream to Read 'OR' End of the Socket Stream