[erlang-questions] Unbuffered/blocking gen_tcp send

David Sveningsson ext@REDACTED
Fri Apr 17 16:58:49 CEST 2009

Hash: SHA1

Matthias Lang wrote:
> Hi,
>> Hi, is it possible to have gen_tcp:send block until the receiver has
>> received the package using gen_tcp:recv? For instance if the sender
>> transmits packages which takes long time to process for the receiver.
> gen_tcp:send can't do this for you. More generally, TCP doesn't provide
> that service. (And: TCP's interface upwards is streams, not packets. The
> packets you get from the {packet, N} modes in gen_tcp are added by Erlang
> on top of TCP)
>> I've been experimenting with the buffer sizes but even setting to sndbuf
>> and recbuf to 1 won't make gen_tcp:send to block, unless the packages
>> are large (1Kb+).
>> I guess it would be possible to manually implement flow-control by
>> acknowledging each package but I would rather just have gen_tcp:send block.
> You've got the right idea. TCP has flow control, but it can't be
> controlled at the fine level you would like it to, i.e. down to
> whether a given "packet" has been received by an application at the
> other end or not. If you want that, you have to implement it yourself
> on top of TCP.
> Matthias

Ok, thanks.
Version: GnuPG v2.0.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


More information about the erlang-questions mailing list