Quantcast
Channel: CNode:Node.js专业中文社区
Viewing all articles
Browse latest Browse all 14821

net 模块 作为服务器对客户端写函数如何独立控制

$
0
0

想实现服务器和客户端建立连接后,服务器可以自由根据配置发送数据到客户端,怎么实现 net.createServer(function(sock) {

// 我们获得一个连接 - 该连接自动关联一个socket对象

    sock.write('You said "' + data + '"');
});

这个sock必须要建立连接后才会有,怎么在外部可以写个函数来定时或者封装自己的write函数呢

Viewing all articles
Browse latest Browse all 14821

Trending Articles