<p>Have you considered having one process for sending and one for receiving (on the same socket)?</p>
<div class="gmail_quote">Den 03/09/2012 06.47 skrev "Satyam Shekhar" <<a href="mailto:satyamshekhar@gmail.com">satyamshekhar@gmail.com</a>>:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<div><br></div><div>I know this question has been asked many times. </div><div><br></div><div><a href="http://erlang.2086793.n4.nabble.com/Non-blocking-sends-in-gen-tcp-td2114537.html" target="_blank">http://erlang.2086793.n4.nabble.com/Non-blocking-sends-in-gen-tcp-td2114537.html</a></div>

<div><a href="https://groups.google.com/forum/?fromgroups=#!topic/erlang-programming/4DBmCK4GAK8" target="_blank">https://groups.google.com/forum/?fromgroups=#!topic/erlang-programming/4DBmCK4GAK8</a></div><div><br></div>
<div>But my concern is slightly different. I have a separate sending/receiving process, P1, for a gen_tcp socket which receives messages it has to send, from process P2. There is no acking between the P1 and P2. Data is buffered at P2 and data acking is client driven, i.e that client says how much data it has received when it reconnects. Right now, P2 sends data to P1 as soon as it generates any data, and also adds it to its buffer, so that it can send it to the client if the socket gets closed before client receives it.</div>

<div><br></div><div>The issue is, since the gen_tcp send call is blocking, and P2 might flood P1s mailbox at times, received messages(socket in active once mode) from the client are delayed quite a bit.</div><div><br></div>

<div>What is the best way to handle this?</div><div><br></div><div>Regards,</div><div>Satyam Shekhar</div>
<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>