Node.js数据传输

时间:2014-11-17 09:13:56

标签: php node.js data-transfer

我正在将数据从节点传输到PHP。我使用相同的URL来传输数据,并且可能需要在循环中调用它超过10次,但它只接受5次。接下来的5将是错误(解析错误)。如何解决?

function win_settings_fn(noos)
    {


                     var str="";
                     var len = str.length ;
                     win_settings.headers = {'Content-length' : len, 'Content-Type': 'application/x-www-form-urlencoded'}     

                     var request = http.request(win_settings, function (response) {
                     response.on('data', function (data) {


                        var response= JSON.parse(data);

                        console.log(str+"respose   ..........."+noos);


                     });

                     response.on('error', function (err) {

                     });

                     response.on('end', function () {

                                       });
                       });


                     request.on('error', function (err) {

                        console.log("failed.............."+noos);

                     });
                     request.write(str +"\0");
                     request.end();

              }

这是我正在使用的代码。

如果我打电话

win_settings_fn(1)
win_settings_fn(2)
win_settings_fn(3)
win_settings_fn(4)
win_settings_fn(5)
win_settings_fn(6)
win_settings_fn(7)
win_settings_fn(8)
win_settings_fn(9)
win_settings_fn(10)

结果是

respose   ...........1
respose   ...........2
respose   ...........3
respose   ...........4
respose   ...........5
failed..............6
failed..............7
failed..............8
failed..............9
respose   ...........10

为什么会这样?发送数据有什么问题吗?

0 个答案:

没有答案