2

This is my node server

var io = require('socket.io').listen(8889);
io.sockets.on('connection', function (socket) {
    socket.emit('news', { hello: 'world' });
    socket.on('my other event', function (data) {
        console.log(data);
    });
});

I am trying to connect to this node server from client side with the help of socket.io.js

I dont have any problem with the connection
My requirement is that I want to create a TCP connection to which clients can connect
But how can I know and confirm the server is a TCP type or HTTP type

4

1 に答える 1

2

Socket.IO はLightweight protocol that sits on top of HTTP.

https://github.com/LearnBoost/socket.io-spec

そこに詳細情報が表示されます https://stackoverflow.com/a/8053026/1012381 しかし、要するに、ブラウザで生データ接続を行うことはできません。

于 2012-12-04T05:54:18.983 に答える