server.close([callback])
callback
<Function> 当 server 被关闭时调用。- 返回: <net.Server>
阻止 server 接受新的连接并保持现有的连接。
该函数是异步的,server 将在所有连接结束后关闭并触发 'close'
事件。
可选的 callback
将在 'close'
事件发生时被调用。
与 'close'
事件不同的是,如果 server 在关闭时未打开,回调函数被调用时会传入一个 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.