建立 TCP、UDP 或 WebSocket 客户端连接。
net.connect(config)
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| config | Object | 是 | 无 | 连接配置,type 必填,支持 tcp、udp、ws。 |
| 类型 | 说明 |
|---|---|
| TcpClient/UdpSocket/WsSocket | 按 type 返回对应连接句柄。 |
client = net.connect({type: 'udp', host: '127.0.0.1', port: 8080}) result = client.type client.close() // 输出:udp print result