如何在c#console应用程序中构建连接多个客户端的服务器? [英] How to build a server that connect between many clients in c# console application?

查看:83
本文介绍了如何在c#console应用程序中构建连接多个客户端的服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

这是我第一次遇到客户端服务器。我试图从互联网上下载客户端服务器代码,但我真的没有找到像我想要的好代码。



我希望应用程序能够做类似的事情:

服务器将保存连接的所有客户端。

其中一个客户端将按摩和reciverId发送到服务器,服务器将发送massege到ID = reciverID的客户。

当客户端发送退出按钮时,客户端与服务器之间的连接将断开。



任何人都可以帮我找到或实现这样的代码吗?

Hello,
It's my first encounter with client server. I'm tried to download a client server code from the internet, but I don't really found a good code like I want.

I want that the application will do something like that:
The server will save the all client that connected.
One of the client will send massage and reciverId to the server, and the server will send the massege to Client who has ID = reciverID.
The connection between client to server will be disconnected when the client will send "EXIT" massage.

Can anyone help me to find or implement such code?

推荐答案

你可以从这个简单的例子开始 C#中TCP客户端服务器简介 [ ^ ]。
You could start with this simple example Introduction to TCP client server in C#[^].


Websockets可以b另一种解决此问题的方法 - Web Socket Server [ ^ ]。
Websockets could be another way to solve this problem - Web Socket Server[^].


请阅读我对你的意见的回复。



我建议浏览 CP知识库 [ ^ ]。你会发现大量的样本。我希望 - 至少 - 一个例子可以满足你的需求。
Please, read my replies to your comments.

I'd suggest to browse CP Knowledge Base[^]. There you'll find tons of samples. I hope that - at least - one example will meet your needs.


这篇关于如何在c#console应用程序中构建连接多个客户端的服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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