Node.js nodejs使用网络模块发送套接字

Node.js nodejs使用网络模块发送套接字,node.js,sockets,Node.js,Sockets,我使用nodejs网络模块发送套接字如下 var client = new net.Socket(); client.connect('8888','127.0.0.1',function(){ for(var i=0; i < 3; i++){ var postData = {}; postData.index = 0; client.write(JSON.stringify(postData)); } }) {"index"

我使用nodejs网络模块发送套接字如下

var client = new net.Socket();
client.connect('8888','127.0.0.1',function(){
    for(var i=0; i < 3; i++){
       var postData = {};
       postData.index = 0;
       client.write(JSON.stringify(postData));
    }
})
 {"index":0}
 {"index":0}
 {"index":0}
但若我将此数据发送到for循环块中,则服务器只接收1个数据包,如下所示:

{“索引”:0}{“索引”:0}{“索引”:0}

有什么解决办法吗?谢谢