> Can anyone tell me what is the low level behaviour of writing to the
> socket OutputStream ? if my loader is sending more messages than the
> server can accept, will the message linger around the network layer
> (possibly on the file handler behind the socket) untill the serve can
> accept it ?
The sending side will buffer a certain amount of data. You can tell how
much with Socket.getSendBufferSize, and set a hint with
setSendBufferSize. On the other side, you have a similar thing with
(get|set)ReceiveBufferSize.
http://java.sun.com/javase/6/docs/api/java/net/Socket.html#getSendBufferSize()
Also of note, is that IP is not a reliable protocol. So TCP needs to
keep hold of the data on the sending side until it is acknowledged. The
receiving side will set a maximum window which determines how much can
be sent without acknowledgment. With a small window and long latency, it
may be the case that the window fills up before a lightly loaded server
can get an acknowledgment back. If the receiver's buffer fills, it will
not accept any more data, causing the sender's buffer to fill and the
sending thread to block.
Tom Hawtin
jlukar@gmail.com - 27 Dec 2006 05:25 GMT
thanks so much for the informative answer. I appreciate it much.
> jlu...@gmail.com wrote:
>
[quoted text clipped - 19 lines]
>
> Tom Hawtin