[erlang-questions] gen_tcp:send(Sock, SmallPacket) issue
David Mercer
dmercer@REDACTED
Tue Jun 19 19:54:20 CEST 2007
>The TCP protocol does not guarantee that a call to 'send' will block
>until your data has actually arrived at the other end.
I don't think what is required is for the send to actually block until the
TCP ack (I forget the name of the packet -- is it a SYN?), but perhaps a
message when the ack comes in. That way, you could block if you wanted to
with something like:
gen_tcp:send(...),
receive {tcp_send_complete, Connection} -> ... end.
Admittedly, in my network programming, I hardly ever do anything with the
TCP ack other than log it.
On the other hand, if the TCP ack never comes in, won't it time out with an
error? If so, you would eventually find out that message was not delivered
when you receive the tcp_error message (or get an error back from
gen_tcp:recv(). I'll try this out if anyone's interested.
On the other hand, I'm not sure that TCP offers much advantage over UDP if
you're going to use application-level acknowledgments. So long as you keep
you messages short enough for a single datagram...
Cheers,
David
More information about the erlang-questions
mailing list