确定socket.io TCP或HTTP [英] Determining whether socket.io TCP or HTTP
本文介绍了确定socket.io TCP或HTTP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的节点服务器
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);
});
});
我试图在 socket.io.js
我没有任何连接问题
我的要求是我要创建一个客户可以连接的 TCP
连接
但怎么能我知道并确认服务器是 TCP
类型或 HTTP
类型
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
推荐答案
Socket.IO是一个轻量级协议,位于HTTP之上。
Socket.IO is a Lightweight protocol that sits on top of HTTP.
https://github.com/LearnBoost/socket.io-spec
您可以在 https:// stackoverflow中查看更多信息。 com / a / 8053026/1012381
但简而言之,浏览器无法连接原始数据。
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.
这篇关于确定socket.io TCP或HTTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文