<div>Forgive me, I must not have explained my situation very well.<br></div><div><br></div><div>I have an Erlang process acting as the server. It accepts tcp and udp connections. I have various clients that connect to my server. When one of those clients disconnect from my server, I get the {tcp_closed, S} message. However, from within my Erlang server, if I call gen_tcp:close(S), the controlling process does not receive the {tcp_closed, S} message.<br></div><br>I am looking for a way to fully emulate the disconnect / close from the client within my server. As I said previously, I can just send the {tcp_closed, S} message from within my own application. I'm just not sure what else, if anything, the VM does when a socket is closed from the other end.<br><br>For reference, I am writing a testing tool that will randomly kill processes and sockets in order to test that your BEAM application(s) can properly handle the non-happy paths that the real world may bring to your application.<br><br>Justin<br><div><br></div><div>‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐<br></div><div> On Thursday, 21 February 2019 13:43, Boshan Sun <<a href="mailto:sunboshan@gmail.com">sunboshan@gmail.com</a>> wrote:<br></div><div> <br></div><blockquote class="protonmail_quote" type="cite"><div dir="ltr"><div dir="ltr">Here's a really simple repo to demonstrate the usage of gen_tcp/gen_udp. <a href="https://github.com/sunboshan/socket">https://github.com/sunboshan/socket</a><br></div><div dir="ltr"><br></div><div>You can follow the tcp.erl to use gen_tcp to set up a server, then use gen_tcp to connect to the server as a client. When one end disconnect, the other end will simply get a {tcp_closed, Socket} message. Nothing more than that.<br></div><div><br></div><div>Boshan<br></div></div><div><br></div><div class="gmail_quote"><div dir="ltr">Justin Wood <<a href="mailto:justin.k.wood@protonmail.com">justin.k.wood@protonmail.com</a>> 于2019年2月21日周四 上午10:24写道:<br></div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div>Hello,<br></div><div><br></div><div>I have a situation where I am closing a gen_tcp/gen_udp socket within my Erlang application. However, I would really like it to act as if it were disconnected or closed from the other end. Basically I want the {tcp_closed, S} message to be sent to the controlling process.<br></div><div><br></div><div>A simple solution would be to just send the message myself. I'm just not sure if that would have the exact same behaviour (there is probably more to it than just the closed messed) as if the socket were truly disconnected or closed from the other end.<br></div><div><br></div><div>Justin<br></div><div>_______________________________________________<br></div><div> erlang-questions mailing list<br></div><div> <a target="_blank" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br></div><div> <a target="_blank" rel="noreferrer" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a><br></div></blockquote></div></blockquote><div><br></div>