socket.unref()
- 返回: <dgram.Socket>
默认情况下,只要套接字处于打开状态,则绑定套接字将导致它阻止 Node.js 进程退出。
socket.unref()
方法可用于将套接字从保持 Node.js 进程处于活动状态的引用计数中排除,即使套接字仍在监听,也允许进程退出。
多次调用 socket.unref()
没有附加效果。
socket.unref()
方法返回对套接字的引用,因此可以链接调用。
- Returns: <dgram.Socket>
By default, binding a socket will cause it to block the Node.js process from
exiting as long as the socket is open. The socket.unref()
method can be used
to exclude the socket from the reference counting that keeps the Node.js
process active, allowing the process to exit even if the socket is still
listening.
Calling socket.unref()
multiple times will have no addition effect.
The socket.unref()
method returns a reference to the socket so calls can be
chained.