[erlang-questions] gen_tcp send non-blocking in erlang?

Matthias Lang <>
Mon Mar 17 10:55:52 CET 2014


Hi,

Here's an earlier discussion on the same topic:

  https://groups.google.com/forum/#!topic/erlang-programming/pSN3Cl0bBTg

You can use 'send_timeout', but note the warning in the fine manual:

   http://www.erlang.org/doc/man/inet.html#setopts-2

it's basically telling you that the only well-defined thing you can do
after send_timeout is to close the socket.

Another, less satisfactory, approach is to write code like this:

    {ok, Tref} = timer:apply_after(500, erlang, exit, [self(), kill]),
    gen_tcp:send(S, Data),
    timer:cancel(Tref).

---

You haven't really told us what you actually want to do. It could be
that what you want isn't really possible at all, at least not with the
conventional interface to the OS' TCP stack---there are buffers in the
OS and buffers in the Erlang VM which you don't have complete control
over.

If feel you need to heed the dramatic warnings in Max's post, you
should probably ask him to clarify.

Matthias

-----------------------------------------
Date: Monday, March 17
From: Vinoth Kumar <>
To 
Subject: [erlang-questions] gen_tcp send non-blocking in erlang?


> Does gen_tcp supports non-blocking send ?I have tried gen_tcp:send which returns the ok while the packets has not been sent to the receiver. Whether any mechanism in erlang to check the sent message delivary?
> Thanks,Vinoth Kumar J

> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list