net.createConnection()


一个工厂函数,用于创建一个新的 net.Socket,立即与 socket.connect() 建立连接,然后返回启动连接的 net.Socket

【A factory function, which creates a new net.Socket, immediately initiates connection with socket.connect(), then returns the net.Socket that starts the connection.】

当连接建立时,将在返回的套接字上触发 'connect' 事件。最后一个参数 connectListener,如果提供,将作为 'connect' 事件的监听器 一次性 添加。

【When the connection is established, a 'connect' event will be emitted on the returned socket. The last parameter connectListener, if supplied, will be added as a listener for the 'connect' event once.】

可能的语法有:

【Possible signatures:】

net.connect() 函数是该函数的别名。

【The net.connect() function is an alias to this function.】