帮忙制作一个C# P2P聊天程序

发布于 2024-08-28 16:27:30 字数 587 浏览 4 评论 0原文

我想制作一个 P2P 聊天客户端,我想要它做的就是能够向每个对等方发送文本。

我从这个例子中查看了一个聊天客户端: http://www.geekpedia。 com/tutorial239_Csharp-Chat-Part-1---Building-the-Chat-Client.html

我想知道它是否可以转换为 p2p 程序? 如果是这样,那怎么可能?有人可以提供一些代码吗,因为这会有很大帮助。

如果不能,我怎样才能制作一个非常简单的 p2p 聊天程序? 代码和示例将非常有帮助。

顺便说一句,我确实看过这篇文章,但它对我没有帮助: http://msdn.microsoft.com/en-us/library/ms751502。 ASPX

I want to make a P2P Chat client, all I want it to do is to be able to send text across to each peer.

I looked at a Chat Client from this example:
http://www.geekpedia.com/tutorial239_Csharp-Chat-Part-1---Building-the-Chat-Client.html

And am wondering if it can be converted to a p2p program?
If so how can it be and can someone provide some code as it will help a lot.

If it can't how can I make a really simple p2p chat program?
Codes and examples will be very helpful.

btw I did look at this article, but it didn't help me:
http://msdn.microsoft.com/en-us/library/ms751502.aspx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

暖心男生 2024-09-04 16:27:30

我曾经做过一个类似的项目,只使用蓝牙而不是互联网。
我的功能不像 IM 那样聊天,因为它只允许两个人交谈,但我们通过使用 brydgesk 编辑中的技术并将客户端(“说话者”)和服务器(“监听者”)放在一起来使其工作。同一应用程序,服务器仅将收到的消息发送到本地客户端,而不是重新广播到所有连接。

希望这一点对您有所帮助,我认为这并不是帮助您编写整个应用程序的正确位置。

I did a similar project once, only using bluetooth rather than Internet.
Mine wasn't chat so much as IM, since it only allowed for two people to converse, but we got it working by using the technique in brydgesk's edit and having the client ('talker') and server ('listener') together in the same application, in such a way that the server only puts out received messages to the local client, rather than rebroadcasting to all connections.

Hope this little bit is helpful, I don't think this is really the right place to help you write the entire application.

雄赳赳气昂昂 2024-09-04 16:27:30

对于P2P,您需要使用UdpClient 而不是TcpClient。谷歌应该从这里帮助你:)

编辑:抱歉,我在这个答案中做出了错误的假设。如果您想继续使用 TCP,那也可以。不要创建单独的服务器应用程序,而是将服务器代码添加到客户端应用程序中,以便发送者或接收者充当服务器。

For P2P, you need to use UdpClient instead of TcpClient. Google should help you from here :)

Edit: Sorry, I made false assumptions in this answer. If you want to continue using TCP, that's just fine. Instead of creating a separate server application, add the server code to your client application, so that either the sender or receiver acts as the server.

网名女生简单气质 2024-09-04 16:27:30

如果是在内网做,为什么不使用WCF命名管道呢?

If it is to be done on the intranet, why not use WCF named pipes?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文