[erlang-questions] gen_tcp:send timeout

Dmitry Kolesnikov <>
Wed Nov 12 10:16:21 CET 2014


Hello,

I am looking on timeout issue with gen_tcp:send. 
I’ve not discovered yet the reason but my sender process is stacked at
{current_function,{prim_inet,send,3}}

The timeout will help me but I’am confused on the way to achieve it

* gen_tcp provides an option {send_timeout, xxx}. The documentation says "The fact that the send call does not accept a timeout option, is because timeouts on send is handled through the socket option send_timeout."

* there was a recommendation for Heroku to use erlang port directly to handle timeout
send(S, Data, Timeout) ->
   true = erlang:port_command(S, Data, []),
   receive
      {inet_reply, S, Status} -> 
         Status
      after Timeout ->
         {error, timeout}
   end.

What is your experience to on this issue?
What is the best way to handle it in production?

Best Regards, 
Dmitry



More information about the erlang-questions mailing list