为什么要使用 Socket IO 而不仅仅是 Socket? [英] Why Use Socket IO and not just Socket?

查看:37
本文介绍了为什么要使用 Socket IO 而不仅仅是 Socket?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在服务器-客户端程序之前构建过(到目前为止,双方都在 python 中构建).

I've build before server-client programs (both sides where build in python by far).

最近我开始使用 swift 构建应用程序,我的目标是使用 python 向我的应用程序添加后端(我的应用程序是一个聊天应用程序)

Recently I started building app using swift and my goal is to add a backend to my apps using python (My app is a chat app)

我在网上搜索了一个教程来做这个,我只看到两个选项可以在服务器端和移动应用程序之间进行通信,第一个是创建 API(REST)(请求 - 响应) - 我不能使用此解决方案是因为我想要实时聊天.第二个选项是网络套接字(socket.IO).

I searched in the Internet a tutorials to do so, and I only saw two options to communicate between server side and mobile application, the first one is to create an API (REST) (request - response) - I can't use this solution because I want a real-time chat. And the second option was web-sockets (socket.IO).

所以,我的问题是为什么不使用简单的套接字技术(就像我曾经在只有 python 服务器端到 python 客户端时使用的那样 -> 导入套接字)——没有网络套接字

SO, my question is why not use the simple socket technology (like I used to use when it was only python server side to python client side -> import sockets) - no sockets over web

推荐答案

following Features 如果你使用的是 Socket.io 或 socketcluster.io(在 Socket IO 之上开发)

following Features You will get if you are using Socket.io or socketcluster.io (which is developed on the top of Socket IO)

  • 可扩展性:- 它将水平扩展,添加更多节点(横向扩展)&线性(放大)
  • 在压缩消息负载时减少负载大小
  • 通过中间件功能授权
  • 连接断开时自动重新连接

如果您想使用自己的实现,那么您必须注意上述功能/解决方案,以解决用户群增加时出现的问题.

If You want to use your own implementation then you have to take care of the above features/Solutions to problems which arises when User-base is increases.

这篇关于为什么要使用 Socket IO 而不仅仅是 Socket?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆