[erlang-questions] gen_tcp nonblocking send

Per Hedeland <>
Sat May 3 00:35:00 CEST 2008


"Igor Ribeiro Sucupira" <> wrote:
>
>On Fri, May 2, 2008 at 7:53 AM, Per Hedeland <> wrote:
>> "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
>>  >important...")?  :-)
>>
>>  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.
>
>
>I meant the "0 byte sent" case.

I realized that, was just saying that O_NDELAY/O_NONBLOCK don't (in
general) provide it. With some man page browsing, I found that on
FreeBSD you can apparently get the "don't send anything if you can't
send it all" effect by diddling the SO_SNDLOWAT setting (or in fact you
will get it by default if what you're trying to send is smaller than the
default SO_SNDLOWAT) - but on Linux it is at least not documented as
having this effect, and is in any case hardwired to 1 (can't be
changed).

--Per



More information about the erlang-questions mailing list