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.