var net =require('net');
var count=0;
var server = net.createServer(function (conn){
conn.write(
'\r\n > welcome to node-chat!'
+'\r\n >' + count + ' other people are conneted at this time.'
+'\r\n > plaese write your name and press enter:'
);
count++;
conn.on('data',function (data){
// count=100;
console.log(data);;
});
conn.on('close',function(){count--;});
conn.setEncoding('utf8');
});
server.listen(3000, function(){
console.log('\033[96m server listening on *:3000\033][39m')
});
我用telnet客户端连接成功后为什么输入数据,在服务器不显示,我用count=100测试了data事件监听的回调函数,确定是会执行的,可为什么console.log不会打印出东西?