简体   繁体   English

关闭由OTP主管拥有的gen_tcp监听套接字

[英]Closing a gen_tcp listen socket that is owned by an OTP supervisor

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. 一些教程,包括本教程“ 学习一些Erlang” ,显示了OTP管理员将打开并拥有TCP侦听套接字并将其共享给许多将接受连接的工作程序的应用程序。

My question is, how do you close a listen socket owned by a supervisor without a terminate/2 callback function? 我的问题是,如何关闭不具有终止/ 2回调函数的主管所拥有的侦听套接字?

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.) (拥有套接字的进程是创建套接字的进程,除非您调用gen_tcp:controlling_process来重新分配套接字的所有权。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM