我直接写 server.listen('toPHP.sock’,function(){}); 结果报错
events.js:72 throw er; // Unhandled ‘error’ event ^ Error: listen EACCES at errnoException (net.js:904:11) at Server._listen2 (net.js:1023:19) at listen (net.js:1064:10) at Server.listen (net.js:1132:5) at Object.<anonymous> (D:\wwwroot\nodejs\test1\toPHP.js:20:3) at Module._compile (module.js:456:26) at Object.Module._extensions…js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10)
用的是xp的系统
5 回复
Windows平台下用命名管道(named pipe)。
// 示例代码
// Use domain socket in *nix systems or named pipe in Windows system.
var path;
if (process.platform === 'win32') {
path = '\\\\.\\pipe\\pipe-test';
} else {
path = '/tmp/test.sock';
};
var net = require('net');
net.createServer(function(socket) {
console.log('Connected');
}).listen(path);