本文介绍了多个客户端服务器C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们我有一个简单的问题。我是套接字编程的新手,所以请不要生气。

我正在编写一个简单的多客户端 - 服务器应用程序,问题是:当我尝试时总是收到错误断开客户端。

服务器和客户端之间的所有操作(例如接收,发送或连接新客户端)都是异步的 - 我认为这可能会导致此问题。当服务器断开客户端时,我立即收到错误,因为例如EndReceive方法仍在工作。

如何避免这些错误?我应该尝试使用异步断开方法吗?或者这样吗?



提前致谢。



PS抱歉我的英语不好 - 它还在改进。

Guys i've got a simple problem. I am totally new in socket programming, so please don't get angry.
I'm writing a simple multiple client-server app and the problem is: i'm always getting an error when i try to disconnect a client.
All actions between server and client (such a receiving, sending or connecting a new client) are asynchronous - and i think it might cause this problem. When the server disconnects a client I get
immediately an error, because for example EndReceive method is still working.
How to avoid these errors? Should I try to use an asynchronously disconnecting method or sth like this?

Thanks in advance.

p.s. Sorry for my bad English - it's still improving.

推荐答案


这篇关于多个客户端服务器C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 08:59
查看更多