[erlang-questions] gen_tcp nonblocking send
Fri May 2 12:53:35 CEST 2008
"Igor Ribeiro Sucupira" <> wrote:
>But, how do you deal with the situation (definitely not Daniel's case)
>in which you just want to NOT send the message if the buffer is full
>("Oh... system overload... nevermind... I don't want to make the
>situation worst... I'll come back when I have something
Well, definitely not by using O_NDELAY/O_NONBLOCK, since they do not (in
general) provide that functionality - they will let you send however
much that fits in the send buffer and leave you to deal with the rest.
In fact I don't think there is a portable way to do what you're asking
about - i.e. basically check whether there is enough buffer space
without attempting to send anything.
I do think *this* functionality could be useful in Daniel's case though
- he'd probably prefer to queue and possibly eliminate also the message
that hit the "buffer full" condition.
More information about the erlang-questions