无法使用节点js

时间:2018-07-25 06:13:31

标签: node.js sockets

以下是节点js中的简单TCP套接字编程:

var net = require('net');
var client = net.connect(9998, '192.168.0.103');
var http = require('http');
var formidable = require('formidable');
var fs = require('fs');

client.write("Hi\n");
client.on('data', function(data)  {
        console.log(data.toString("utf-8")); // Here I received 'hi' as expected.       
});
client.write("I will send file");
client.on('data', function(data) {
        console.log(data.toString("utf-8"));   //Here, I again received 'hi' though expected 'Ok' message.     
});

我在套接字上收到了相同的消息。有人可以帮我吗?

0 个答案:

没有答案