Determining whether socket.io TCP or HTTP

偶尔善良 提交于 2019-12-24 02:23:22

问题


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


回答1:


Socket.IO is a Lightweight protocol that sits on top of HTTP.

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

You can see more info there https://stackoverflow.com/a/8053026/1012381 But in short you can't have raw data connection by the browser.



来源:https://stackoverflow.com/questions/13696903/determining-whether-socket-io-tcp-or-http

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!