Meaningless Drivel is fun!
The moose likes Sockets and Internet Protocols and the fly likes Please help with Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Please help with" Watch "Please help with" New topic

Please help with

V Johnson

Joined: Jul 28, 2003
Posts: 1
The problem is that my application is hanging on the!! Please help me...

Code Tags added by M^2
[ July 28, 2003: Message edited by: Michael Morris ]
gautham kasinath
Ranch Hand

Joined: Dec 01, 2000
Posts: 583
well, if your program is *hanging* with the buffered reader, then I guess the read() is blocking.
There seems to be nothing on the network i/p buffer and hence the read() blocks, waiting for something to arrive.
It would be great if you can post the client code too.
In the meantime, I will look around the problem with a client of my own.

"In the country of the blind, the one eyed man is the King"
Gautham Kasinath CV at :
Nick Revak

Joined: Jun 08, 2003
Posts: 4
The third parameter in the read is the maximum characters to attempt to read.
You could simply try setting your array size to a value much bigger than your would ever expect for contentLength.
But I also think you'd want to do your reads within a while loop (checking for end of stream). If you do this, you need to manage the size of each read to ensure you don't exceed your array.
Try this ....
int currentArrayPos = 0;
int count = 0;
//then, change the max char parameter in your read ....
while ((count =, 0, contentLength - currentArrayPos) != -1 ) {; //***HERE'S THE PROBLEM!!
// and limit the size of each read
currentArrayPos = currentArrayPos + count
I agree. Here's the link:
subject: Please help with
It's not a secret anymore!