[erlang-questions] tcp connection with timeout
Wed Oct 14 23:43:55 CEST 2009
> is there a way to discard any message from peer after set timeout occurs? A
> server should respond in given time or transmission should be repeated.
> I implemented small ex where one process is listening and responding in
> random time (let say 1 to 3 sek). and it is always accepting exactly one
> process during its life.
I'm not entirely sure what you mean by "accepting exactly one process".
> other process is connecting via tcp and is sending msg. I set send_timeout
> flag for socket and a timer on receive after to let say 500ms and 1000ms so
> it should get timeout all the time.
send_timeout does not do what you seem to think it does. The
acknowledgement of the send is generated by the far end's TCP stack
before your code ever sees the packet.
> when I receive timeout I send special msg that server should repeat last
> response. all this is great but then I will receive two responses from
> server with timeouted and then repeated msg.
> in fact Im receiving all "lost" messages that were sent to my client by
> server. I could maybe add some ticket to the msg and take out any incoming
> messages that are not matching but this is impossible right now (afac) as I
> will break protocol.
I think your basic problem here is that you're using TCP, but trying to
re-implement part of it (lost/timed-out message retransmission) on top
of it. If you want to tinker with stuff at that level, use a UDP
More information about the erlang-questions