[erlang-questions] gen_tcp nonblocking send

Dave Smith dizzyd@REDACTED
Thu May 1 00:22:14 CEST 2008


It is my understanding that gen_tcp:send never blocks, since it's just
queuing up a message for the process handling the socket.  If I had to
guess, I'd say that under the covers it's queuing up the data using
the driver_enq (see ERTS erl_driver) and then when the socket is ready
to write, the VM pushes that data into the socket (since all sockets
are non-blocking in the VM, or so I would presume).

Hope that helps...

D.

On Wed, Apr 30, 2008 at 3:38 PM, Daniel Ginsburg <dg@REDACTED> wrote:
> Is there any way to make gen_tcp:send operate in non-blocking mode?
>
>  As I read the documentation, there are two possible ways to handle
>  stalling reader:
>  1) block forever
>  2) use {send_timeout, N} and when timeout occurs, close the socket.
>
>  In my application 2 is unacceptable and 1 is suboptimal.
>
>  What I'd really like to have is an opportunity to know that kernel send
>  buffer is filled and send would block, and conversely, when stalled
>  receiver has recovered and I can send more data. It that possible with
>  standard erlang library? I'd really hate to write my own driver to
>  handle this.
>  _______________________________________________
>  erlang-questions mailing list
>  erlang-questions@REDACTED
>  http://www.erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list