异步套接字,正在寻找解释 [英] Asynchronous sockets, looking for explanation

查看:116
本文介绍了异步套接字,正在寻找解释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正计划创建一个异步套接字客户端-服务器体系结构,但是我有一些问题要问,以便它可以为我澄清一些事情.我过去曾经构建过REST架构,但是这是我第一次使用套接字.

举例来说,我想创建一个简单的聊天室,我了解服务器会保留所有已连接客户端的套接字集合,并且在收到消息后,我将遍历该集合以广播发送消息给所有客户.

现在,假设我也支持文件传输,并且服务器正在将一个很大的文件传输到客户端,如果在这段时间内广播聊天消息并且文件传输未完成,会发生什么?即使客户端已经在与服务器通信以传输文件,客户端也会收到消息吗?如果不是这种情况,我应该如何处理?

在此先感谢!

Hi, I am planning to create an asynchronous sockets client-server architecture, however I have some questions to ask so it can clarify some things for me. I have build multiples REST architecture in the past but its my first time with sockets.

So lets say for example that I would like to create a simple chat, I understand that the server keep a sockets collections of all the connected clients and upon the reception of a message I''ll just loop throught that collections to broadcast send the messages to all client.

Now, lets say that I also have support for file transfer and that the server is transfering a very big file to a client, what will happen if a chat message is broadcasted during this time and the file transfer is not completed? Will the client receive the message even if he is already communicating with the server to transfer a file? How should I deal with this if its not the case?

Thanks in advance!

推荐答案

不,怎么办?您可以为不同的目的使用单独的IO端口.您可以使用一个端口进行快速"消息交换,使用一个端口进行慢速"文件传输.或等待:-).

—SA
No, how? You can have separate IO ports for different purposes. You may use one port for "quick" message exchange, one for for "slow" file transfers. Or wait :-).

—SA


这篇关于异步套接字,正在寻找解释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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