wood burning stoves 2.0*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 19649
    
  18

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Length of the Socket Input Stream to Read 'OR' End of the Socket Stream
 
Similar Threads
SocketChannel question
Length of the Socket Input Stream to Read 'OR' End of the Socket Stream
Problem with available method
FileInputStream.read(byte []) question
Exception while writing to outjava.net.SocketException: Socket closed