使用GZipStream进行客户端/服务器异步通信 [英] Using GZipStream for Client/Server Async Communication

查看:126
本文介绍了使用GZipStream进行客户端/服务器异步通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个客户端和单个服务器的客户端/服务器系统(使用Socket),它在所有客户端上每秒钟发送xml数据。

I have Client/Server System (using Socket) with multiple clients and single server, which is sending xml datas every seconds on all clients.

XML数据始终在1到18000个字符之间的不同大小,并且服务器需要同时将这些XML数据发送到所有客户端。

The XML datas are always in different size between 1 - 18000 characters and server needs to send these XML-Datas to all clients at the same time.

现在我想知道如何使服务器和客户端之间的通信更快。

Now I want to know, how to make the communication between the server and clients faster.


  • 我应该发送之前压缩每个XML数据?

  • 我应该序列化 XML数据吗? (可能xml数据大小会减少)

  • 我需要将每个XML数据转换为byte []数组(用于缓冲区),
    ,因为通信必须完成

  • Should I compress every XML-Data before sending?
  • Should I serialize the XML-Datas? (maybe the xml data size will be decreased)
  • Do I need to convert every XML-Datas into byte[] array(for buffer), because the communication must be done at the sametime for all clients.

谢谢!

推荐答案

如果您正在迭代连接的客户端,您可以使用具有内置pub-sub拓扑的中间层。 0MQ 能够让单个发布商非常有效地发送给n个订阅者,并具有C#绑定。您也可以在按照建议发送邮件之前压缩邮件。

You could use a middle layer with built in pub-sub topology if you are currently iterating through your connected clients. 0MQ has the ability for a single publisher to send to n subscribers very efficiently and has a C# binding. You could also compress the messages before being sent as you suggested.

这篇关于使用GZipStream进行客户端/服务器异步通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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