有人可以告诉我如何将 linemode 设置为 telnet 测试吗?我google了很多,但不幸的是我没有成功。我有这个超级简单的代码
var net = require('net');
var server = net.createServer(function(c) {
console.log('socket opened');
c.setEncoding('utf8');
c.on('end', function() {
console.log('connection/socket closed');
});
c.on('data', function(data) {
console.log('Data:'+data);
c.write('Answer:'+data);
// c.end(); // close socket/conection
});
});
server.listen(8124, function() { // start server (port 8124)
console.log('server started');
});
但测试看起来像这样:
客户:
Microsoft Telnet> open localhost 8124
Answer:dAnswer:daAnswer:atAnswer:taAnswer:a
服务器:
C:\Users\Laura\node server.js
server started
socket opened
Data:d
Data:a
Data:t
Data:a