[erlang-questions] Non-blocking sends in gen_tcp?

Cayle Spandon cayle.spandon@REDACTED
Wed Mar 11 16:19:53 CET 2009


Does gen_tcp provide a mechanism for non-blocking sends, similar to the
traditional send and select/poll calls in Unix, in the following sense:

-1- When you call gen_tcp:send() with N bytes and flow-control kicks in,
gen_tcp:send()returns immediately (i.e. does not block, not even for some
small time-out). The return value indicates that flow-control was invoked
and gives some indication of what subset of bytes was accepted (e.g. by
returning the remaining unsent binary). This is similar to Unix send()
returning EAGAIN.

-2- Some mechanism to inform the sending process that the socket is ready to
send more data, e.g. an Erlang message. This is similar to Unix select()
reporting that a socket is ready-to-send.

I have considered the option of creating an Erlang process dedicated to
sending messages over the socket and using blocking gen_tcp:send calls in
that process. For various reasons  (related to the fact that a send may have
to be interruped by some other activity) this is not an option for me.

I found some references to the prim_inet module on Google, but evidently
that is not an officially documented module.

PS - My apologies if this question has already been answered. I googled the
topic and found many discussions but not quite the answer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090311/172eba21/attachment.htm>


More information about the erlang-questions mailing list