如何实现多线程客户端服务器应用程序?需要建议。 [英] How to implement multi-threaded client server application? Need suggestion.

查看:79
本文介绍了如何实现多线程客户端服务器应用程序?需要建议。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设有许多客户端通过服务器向任何其他客户端发送消息,并且此处使用套接字编程和线程。服务器如何区分特定目标客户端并将其转发给消息。需要建议。谢谢。

suppose there are many clients whose are sending message to any other client via server and here socket programming and thread are used. how does server distinguish particular destination client and forward it the message. Need suggestion. Thanks.

推荐答案

作为一种简单的方法,您的客户可以发送包含实际数据(有效负载)和附加信息的消息,这对于正确传递消息本身很有用(例如,参见有效载荷维基百科页面 [ ^ ])。根据这些附加信息,服务器可以将消息分发给目标客户端。
As a simple approach, your clients could send messages containing either the actual data (the payload) and additional information, useful to deliver correctly the message itself (see, for instance the "payload" Wikipedia page[^]). Based on such additional information the server could dispatch the messages to the destination clients.


这篇关于如何实现多线程客户端服务器应用程序?需要建议。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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