[erlang-questions] tcp_closed message
Justin Wood
justin.k.wood@REDACTED
Thu Feb 21 20:03:07 CET 2019
Forgive me, I must not have explained my situation very well.
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.
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.
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.
Justin
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Thursday, 21 February 2019 13:43, Boshan Sun <sunboshan@REDACTED> wrote:
> Here's a really simple repo to demonstrate the usage of gen_tcp/gen_udp. https://github.com/sunboshan/socket
>
> 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.
>
> Boshan
>
> Justin Wood <justin.k.wood@REDACTED> 于2019年2月21日周四 上午10:24写道:
>
>> Hello,
>>
>> 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.
>>
>> 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.
>>
>> Justin
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190221/4f710b9c/attachment.htm>
More information about the erlang-questions
mailing list