gen_tcp bug?

Bernardo Paroli erlang@REDACTED
Mon Aug 9 20:01:41 CEST 2004


mmmm, I waiting for gen_tcp:send finalization.
Do I need to handle time outs in my application?
If I do handle time outs, the next code is correct?

sendToClient(Socket, Message) ->
  Self = self(),
  Pid = proc_lib:spawn(fun() -> send(Socket, Message, Self) end),  %% spawn
process to send message
 receive %% Wait for send response
  {Pid, sent} ->
    ok

  after ?TIMEOUT ->
      erlang:exit(Pid, kill),                         %% Kill process if
send response don't arrive
      timeout
 end.

send(Socket, Message, From) ->
 gen_tcp:send(Socket, Message),
 From ! {self(), sent}.


----- Original Message ----- 
From: "Luke Gorrie" <luke@REDACTED>
To: "Bernardo Paroli" <erlang@REDACTED>
Cc: <erlang-questions@REDACTED>
Sent: Monday, August 09, 2004 1:17 PM
Subject: Re: gen_tcp bug?


> "Bernardo Paroli" <erlang@REDACTED> writes:
>
> >  I have noticed that when a conecction is established and if I
> > disconnect the network cable and connect this 30 seconds later the
> > gen_tcp:send function locks infinitely but it doesn't fail(this lock
> > happens at prim_inet:send/2).
> >
> > Why does this happen ? Why doesn't the gen_tpc:send/2 function fail?
>
> How long do you wait before giving up?
>
> Generally if you have an outage for N seconds then it will take TCP up
> to N*2 seconds to retransmit and recover. So you should wait at least
> a minute after putting the plug back in.
>
> -Luke
>
>





More information about the erlang-questions mailing list