[英]Open port 23 to read data using Node.js
On my windows laptop there is a program with a TCP/IP server on port 23. I can open it with a telnet terminal and see the data streaming. 在我的Windows笔记本电脑上,有一个程序在端口23上带有TCP / IP服务器。我可以使用telnet终端打开它,然后查看数据流。 I need to get that data into a node.js program I'm working on.
我需要将这些数据放入正在处理的node.js程序中。 Should be easy but I haven't found any code examples.
应该很容易,但是我还没有找到任何代码示例。 Searches come up with lots of examples of how to make a server on port 23 with Node.js.
搜索提供了许多有关如何使用Node.js在端口23上构建服务器的示例。
Thanks 谢谢
This is a high level TCP/IP socket implementation in node. 这是节点中的高级TCP / IP套接字实现。 See: Node net API
请参阅: Node net API
var net = require('net'),
port = 23,
host = 'localhost',
socket = net.createConnection(port, host);
socket
.on('data', function(data) {
console.log('received: ' + data);
})
.on('connect', function() {
console.log('connected');
})
.on('end', function() {
console.log('closed');
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.