Questions regarding TCP sockets

Shafia Kausar eusshkx@REDACTED
Fri Nov 9 18:35:44 CET 2001


Hi,

I currently have an active TCP socket which is getting swamped by bursts
of short messages sent by the other end resulting in processor overload.
I would like to introduce flow control to prevent incoming bursts of
data, for which, I understand that I need to change the socket to a
passive mode. 

But I am not sure how to implement the receipt of packets from the
socket. More precisely  - what is the difference between an active and
passive socket? How does a passive socket introduce flow control? 

What is the purpose of the length parameter in the function call  

	gen_tcp:recv(sock, length).

i.e. how is the length related to the receive buffer of TCP

So far the only difference in behavior I have seen is that the active
socket reads every message it receives and sends it to the application,
while a passive socket requires the user to read the socket. I am
assuming that reading of the socket at intervals rather than
continuously introduces flow control.

If my above assumption is correct -  how frequent should the read be to
introduce an optimum flow control mechanism? How many bytes do we read
at a time? Does the length parameter control the size of the receive
buffer/advertised receiver window? How much of additional flow control
do we achieve by using the timeout parameter in gen_tcp:recv/3 
 
Can I have two different processes interacting with the passive socket
-  one process reads the socket in a loop while the other sends to the
socket? I was thinking about this to free the process which would
otherwise be tied to the receive loop. Would this beat the whole purpose
of the passive socket? 

What are the default values of the send/receive buffer in OTP? I
understand that these are set by the OS and are also configurable when
we define the socket parameters but if this is not defined by the user
does OTP override the OS defaults (possibly?)

I am sorry about the long list of questions but I have used all
resources I could find and have come to a dead end. Hopefully the
experts on this list can help me out:))

Also - Is there any documentation which explains in detail the
implementation of sockets in OTP (other than the man pages). Especially
how flow control and congestion control is implemented. 

Thanks!

regards,
Shafia



More information about the erlang-questions mailing list