AFAIK, data doesn't get lost except if the socket is closed from the other side.<br><br><div class="gmail_quote">On Fri, Dec 30, 2011 at 6:32 PM, Roberto Ostinelli <span dir="ltr"><<a href="mailto:roberto@widetag.com">roberto@widetag.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>thank you klaar,</div><div><br></div><div>though there's something I don't like in the proposed solution: what if you receive more than the intended original N bytes? there's the (un)famous undocumented option gen_tcp:unrecv but i'd rather not use it, plus there isn't an SSL equivalent for it.</div>
<div><br></div><div>storing the additional received bytes for later usage seems cumbersome, and sometimes even unfeasible when considering that I'm often switching the packet type and the active options of inet.</div>
<div><br></div><div>i was thinking to wrap the gen_tcp:recv/3 function around something that re-calls it if it timeouts, but unfortunately when it does the returned error {error, timeout} does *not* contain the bytes received up to that point, which then get lost.</div>
<div><br></div><div>..anyone?</div><div><br></div><br><div class="gmail_quote"><div class="im">On Tue, Dec 27, 2011 at 7:52 AM, Magnus Klaar <span dir="ltr"><<a href="mailto:magnus.klaar@gmail.com" target="_blank">magnus.klaar@gmail.com</a>></span> wrote:<br>
</div><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi!<div><br></div><div>gen_tcp:recv(..., N, M) returns {error, timeout} if N bytes has not been received after M milliseconds. If less bytes are available the call will _not_ succeed. If you are receiving data at a slow rate specifying 0 as the length is preferrable because the call will return whatever data is available at the time. If there is no data available it will wait and timeout if no data has been received after M milliseconds. If you don't want to timeout at all when doing this, specify infinity as the timout value.</div>
<div><br></div><div>MVH Magnus<br><br><div class="gmail_quote"><div>On Tue, Dec 27, 2011 at 2:10 AM, Roberto Ostinelli <span dir="ltr"><<a href="mailto:roberto@widetag.com" target="_blank">roberto@widetag.com</a>></span> wrote:<br>
</div><div><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
dear list,<br><br>when calling gen_tcp:recv/3 by specifying a length and a timeout, when will {error, timeout} be a response? Is it:<br><br>1. when no bytes are received for a period longer than the specified Timeout<br>
2. when the number of bytes specified in Length is not received within Timeout<br>
<br>if 2, what is the best solution to actually *not* have a recv/3 timeout while receiving bytes at a very low pace (for instance on very slow connections)?<br><br>thank you,<br><br>r.<br></blockquote></div></div></div>
</div>
</blockquote></div></div></div><br>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Best Regards,<br>- Ahmed Omar<div><a href="http://nl.linkedin.com/in/adiaa" target="_blank">http://nl.linkedin.com/in/adiaa</a></div><div>Follow me on twitter</div>
<div><a href="http://twitter.com/#!/spawn_think" target="_blank">@spawn_think</a></div><br>