为什么 socket.setNoDelay() 会抛出错误?

Why is socket.setNoDelay() throwing an error?

我有一个使用 socketio 进行实时通信的 nodejs 服务器。

var app = require('http').createServer(handler)
  , io = require('socket.io')().listen(app)

function init() {
    app.listen(process.env.PORT || 8888);
};

io.sockets.on('connection', function (socket) {
    socket.setNoDelay(true);
    onSocketConnection(socket);
});

问题是,每次我调用 socket.setNoDelay(true);它正在反弹:

E:[path]\server.js:58
  socket.setNoDelay(true);
         ^
TypeError: undefined is not a function
    at Namespace.<anonymous> (E:\[path]\server.js:58:12)   
    at Namespace.emit (events.js:107:17)
    at Namespace.emit (E:\path]\node_modules\socket.io\lib\namespace.js:205:10)   
    at E:\[path]\node_modules\socket.io\lib\namespace.js:172:14
    at process._tickCallback (node.js:355:11)

我似乎找不到任何文档来说明为什么会发生这种情况。还有其他人看到这个吗?

规格:

> Windows Environment  
> node version: 0.12.4 
> socket.io version: 1.3.6

因为 socket 不是 net.Socket, it's a socket.io Socket。您会注意到 socket.io Socket.

上没有 setNoDelay 方法

socket.io websocket 服务器automatically disables Nagle on the underlying TCP socket