我通过 express
(see docs)启动了一个unix域套接字监听器:
app.get('/', function(req, res) {
res.send('hello world');
});
app.listen('/tmp/sock', () => {
fs.chmodSync('/tmp/sock', '0777');
});
这正确旋转但当我尝试创建客户端并向其发送数据时,我的 /
路由永远不会返回 'hello world'
. 这是我的客户端代码:
const net = require('net');
const client = net.createConnection({ path: '/tmp/sock', port: '80' }, () => {
console.log('connected to server!');
client.write('hello');
});
client.on('end', () => {
console.log('disconnected from server');
});
我错过了什么?