[erlang-questions] TCP Flow Control

Joel Reymont <>
Sun Jun 14 19:02:36 CEST 2009


{active, once} should do it, e.g after accepting

     inet:setopts(Socket, [{active, once},
                           {packet, 0},
                           binary]),

and then

handle_info({tcp, Socket, Bin}, State)
   when Socket == State#state.socket ->
     inet:setopts(Socket, [{active, once}]),
     {ok, State1} = dispatch(Bin, State),
     {noreply, State1};

On Jun 14, 2009, at 4:42 PM, Evans, Matthew wrote:

> My understanding of Erlang however is that gen_tcp will read from  
> the socket as fast as it can, and dispatch the data to the calling  
> Erlang process (in effect filling up its message queue if it is  
> reading too slowly). Are there any options that can be set to  
> override this behavior, or provide some sort of back pressure to  
> gen_tcp causing it to read from the socket slowly?

---
Mac hacker with a performance bent
http://www.linkedin.com/in/joelreymont



More information about the erlang-questions mailing list