[erlang-questions] etimedout from gen_tcp:recv - or definition of infinity

Stefan Hellkvist hellkvist@REDACTED
Mon Sep 23 08:10:21 CEST 2013


Sorry about this...pressed send by mistake (should never write the address
before completing the message):

I'll try again:
The code went in the first message there (below), but here is my question:

How can I get a etimedout message from gen_tcp:recv in this case? I get it
if I leave the the connection idling for a couple of hours. The clients
initially connect to the server, sends some messages, and then go idle and
the server then get etimedout.

According to the manual pages of gen_tcp all default values for timeout
values are set to infinity which to me would imply that the connection can
close and all that and experience other errors but I should at least never
get a etimedout value unless the length of "infinity" is highly
exaggerated.

Does anyone have any idea why I can get the etimedout response from
gen_tcp:recv in this case? Have I misunderstood the documentation?

This happens on R15B01 on Ubuntu 12.04 64bit server.

Kind regards,
Stefan Hellkvist


On Mon, Sep 23, 2013 at 8:01 AM, Stefan Hellkvist <hellkvist@REDACTED>wrote:

> Hi,
>
> Here is a question about why I sometimes get an etimedout error from
> gen_tcp:recv.
>
> I open a tcp socket on the server side using lines like:
>
> {ok, LSock} = gen_tcp:listen(Port, [binary, {packet, line}, {active,
> false}]),
> {ok, Sock} = gen_tcp:accept(LSock),
> do_recv(Sock).
>
>
> where do_recv is something like this:
>
>
> do_recv(Sock) ->
>     case gen_tcp:recv(Sock, 0) of
>         {ok, Data} ->
>             %handle data
>             do_recv(Sock);
>
>         {error, Reason} ->
>             log("tcp_bus got error and shut down: ~p", [Reason])
>     end.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130923/aadd07c8/attachment.htm>


More information about the erlang-questions mailing list