问题描述
大家好!
我正在编写小应用程序,通过udp发送文本数据。
在服务器端,我有一个用于发送和接收数据的异步UDP套接字。
在客户端,我有相同的异步UDP套接字。
当客户端向服务器发送数据时,然后立即退出应用程序而不等待服务器的响应,服务器端发生错误。
错误:强制关闭现有连接由远程主机。
我明白这个错误意味着我可以在服务器上重新创建套接字,但是此时发送或接收数据的所有客户也会看到错误并丢失一些数据。
要修复它我可以创建单独的套接字用于发送和接收但在我看来,这是错误的解决方案。关于这个问题的另一个想法是检查死亡客户端,但我不知道我怎么做到这一点。
也许有人对这个问题有任何想法?
我是c#的新手....不要发誓=)
Hello all!
I'm writing small app for sending text data via udp.
On server side i have one async UDP socket for sending and receiving data.
On client side i have same async UDP socket.
When the client sends data to the server, then immediately exit the application without waiting for a response from the server, an error occurs on the server side.
Error: An existing connection was forcibly closed by the remote host.
I understand that this error means and I can re-create the socket on the server, but all clients who at this moment send or receive data also will see an error and will lose some data.
To fix it I can create separate sockets for sending and receiving.But it seems to me that this is the wrong solution. Another idea about this problem is check deads clients, but i don't know how i can do this.
Maybe someone has any idea about this problem?
i'm new in c#....do not swear much =)
推荐答案
这篇关于在通过UDP发送数据之前,C#检查客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!