server.listen(handle[, backlog][, callback])
handle<Object>backlog<number>server.listen()函数的常用参数callback<Function>- 返回:<net.Server>
启动一个服务器,在指定的 handle 上监听连接,该 handle 已经绑定到一个端口、Unix 域套接字或 Windows 命名管道。
🌐 Start a server listening for connections on a given handle that has
already been bound to a port, a Unix domain socket, or a Windows named pipe.
handle 对象可以是服务器、套接字(任何带有底层 _handle 成员的东西)、BoundSocket,或者是带有 fd 成员且该成员是有效文件描述符的对象。
🌐 The handle object can be either a server, a socket (anything with an
underlying _handle member), a BoundSocket, or an object with an fd
member that is a valid file descriptor.
当 handle 是一个 BoundSocket 时,服务器会采用已绑定的套接字并开始监听它。采用会消耗该已绑定的套接字(参见 所有权转移)。
🌐 When handle is a BoundSocket, the server adopts the already-bound
socket and starts listening on it. Adoption consumes the bound socket (see
ownership transfer).
Windows 不支持监听文件描述符。
🌐 Listening on a file descriptor is not supported on Windows.