Archived

This topic is now archived and is closed to further replies.

[java] Java Sockets

This topic is 6532 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does anyone know what happens if you send more than the client''s (or downstream) buffer can handle? In my poorly constructed program both apps stall indefinitely. JoeG

Share this post


Link to post
Share on other sites
Also, how can I tell what the size of the send/recieve buffers are in JDK 1.1 ?

Share this post


Link to post
Share on other sites
Did you try setting the initial size of the buffer?
BufferedInputStream(InputStream in, int size);
I think the program would crash if you sent more data than the buffer could handle, because the buffer tries to accomodate by resizing it''s internal array. The only way I can think of to flood it would be to send more data than the client has in RAM. Then your program would most likely die with an OutofMemory runtime error.

Share this post


Link to post
Share on other sites
Well I almost asked the question "How do you set the size of the socket send/receive buffers" but decided to look at my JDK docs first (the docs that go with 1.2, I''m working with 1.1) and I found the functions to do that. Pleasantly surprised, I set to work on using those functions. Needless to say, I was dissapointed to find out that JDK 1.1 didn''t support Socket::setReceiveBufferSize(int)/Socket::setSendBufferSize(int) (first clue was the red syntax error the JBuilder was giving me immediately after I typed it in ). I''m thinking that the stream i/o functions wouldn''t help because Sun added the Socket::Send/Receive]BufferSize(int) to JDK 1.2, when that would''ve been duplicating the functionality of InputStream::setBufferSize().
Now, I didn''t crash my computer (I could even CTRL+C out of the apps), but all feedback I had set up wasn''t being sent to either of the DOS windows (client one and server one). I have experimented and found that sending around 10 KB at one time will work. Sending a MB won''t. So, I guess that these Sockets prefer sending chunks of data under a certain limit (whatever that is in JDK 1.1). But I would like to know for certain....

Share this post


Link to post
Share on other sites