Node.js服务器接收2个请求

时间:2013-05-05 12:51:17

标签: node.js curl

我有node.js服务器端:

var http = require('http');
var server = http.createServer(function (req, res) {
    console.log(req.url);
}).listen(10001);
var io = require('socket.io').listen(server);

我尝试从PHP连接到此服务器,使用curl:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://'.$address);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($ch, CURLOPT_PORT, $port);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data,true));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$ret = curl_exec($ch);
curl_close($ch);

为什么当我只有1时,我得到2个服务器请求(控制台显示网址“/”)? 我尝试使用socket.io进行聊天,并且需要从PHP执行一些操作。

0 个答案:

没有答案
相关问题