server.close([callback])
callback
<Function> 服务器关闭时调用。- 返回: <net.Server>
停止服务器接受新连接并保持现有连接。
该函数是异步的,当所有连接都结束并且服务器触发 'close'
事件时,则服务器最终关闭。
一旦 'close'
事件发生,则可选的 callback
将被调用。
与该事件不同,如果服务器在关闭时未打开,它将以 Error
作为唯一参数被调用。
callback
<Function> Called when the server is closed.- Returns: <net.Server>
Stops the server from accepting new connections and keeps existing
connections. This function is asynchronous, the server is finally closed
when all connections are ended and the server emits a 'close'
event.
The optional callback
will be called once the 'close'
event occurs. Unlike
that event, it will be called with an Error
as its only argument if the server
was not open when it was closed.