net.createConnection(port[, host][, connectListener])
-
port<number> 套接字应连接到的端口。将传递给socket.connect(port[, host][, connectListener])。¥
port<number> Port the socket should connect to. Will be passed tosocket.connect(port[, host][, connectListener]). -
host<string> 套接字应连接到的主机。将传递给socket.connect(port[, host][, connectListener])。默认值:'localhost'。¥
host<string> Host the socket should connect to. Will be passed tosocket.connect(port[, host][, connectListener]). Default:'localhost'. -
connectListener<Function>net.createConnection()函数的公共参数,发起套接字上的'connect'事件的 "once" 监听器。将传递给socket.connect(port[, host][, connectListener])。¥
connectListener<Function> Common parameter of thenet.createConnection()functions, an "once" listener for the'connect'event on the initiating socket. Will be passed tosocket.connect(port[, host][, connectListener]). -
返回:<net.Socket> 用于启动连接的新创建的套接字。
¥Returns: <net.Socket> The newly created socket used to start the connection.
发起 TCP 连接。
¥Initiates a TCP connection.
此函数创建新的 net.Socket,所有选项都设置为默认值,立即启动与 socket.connect(port[, host][, connectListener]) 的连接,然后返回启动连接的 net.Socket。
¥This function creates a new net.Socket with all options set to default,
immediately initiates connection with
socket.connect(port[, host][, connectListener]),
then returns the net.Socket that starts the connection.