[erlang-questions] tcp_closed message

Loïc Hoguin essen@REDACTED
Thu Feb 21 22:57:50 CET 2019


The idea is to have a normal application running and creating havoc (a 
la chaos monkey) in it without any code change (the remote end might not 
be on the same host anyway). Just start havoc, wait a little, stop it, 
and see if your application is still in a good state.

The ability to close sockets like this might require either a change in 
OTP to allow this or using os:cmd or similar to do it at the OS level. 
But hopefully there's a portable solution.

On 21/02/2019 22:38, Dmitry Belyaev wrote:
> Can you make your test code to actually open a connection to the server 
> you are testing? There is nothing wrong in doing that from inside the 
> same Erlang node. Then you'd be able to close that client socket and 
> observe tcp_closed on the controlling process
> 
> On 22 February 2019 05:23:53 GMT+11:00, Justin Wood 
> <justin.k.wood@REDACTED> wrote:
> 
>     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
> 
> 
> -- 
> Kind regards,
> Dmitry Belyaev
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
> 

-- 
Loïc Hoguin
https://ninenines.eu



More information about the erlang-questions mailing list