Reputation: 367
A few tutorials, including this Learn You Some Erlang one, show applications where an OTP supervisor will open and own a TCP listen socket and share it to a number of workers, who will accept connections.
My question is, how do you close a listen socket owned by a supervisor without a terminate/2 callback function?
Upvotes: 2
Views: 82
Reputation: 41618
The socket is linked to the process that owns it. If that process exits, the socket is automatically closed. (This goes for both listening sockets and connection sockets.)
(The process that owns the socket is the process that created it, unless you've called gen_tcp:controlling_process
to reassign ownership of the socket.)
Upvotes: 4