问题描述
强制使用专用套接字。
和
如果服务器丢失与客户端的UDP连接,它将...
我认为UDP套接字是无连接!
那么失去连通性是什么意思呢?和如何避免呢?
有一种已知的方法来确保专用套接字?
感谢
对我来说,这说明,为每个连接创建一个唯一的套接字,并在整个连接使用它。
编辑:从服务器的角度来看,只是为了扩展。
这样服务器可以区分每个消息来自哪个客户端。由于远程地址由IP地址和端口组合组成,因此在服务器的整个通信过程中应使用相同的套接字。这是因为如果你不这样做,那么下次更改底层套接字时,可能会分配不同的端口。
可能松散UPD连接连接中的任何一个端点都会丢失,比如我去服务器并拔插头?
EDIT2:
Dan Bryant在
- I am supposed to connect to external server using UDP sockets in C#..
- I could not understand these 2 lines in server usage notes:
"Use of dedicated sockets is enforced."
and
"If the server looses UDP connectivity with the client, it will ..."
I thought that the UDP socket is connectionless!So what did "looses connectivity" mean? and how to avoid it?Does there is a known way to ensure "dedicated sockets"?
Thanks
To me this says, create one unique socket for each connection and use it throughout that connection.
EDIT: Just to expand on this, from the servers point of view.
That way the server can distinguish from which client each message came from. Because the remote address is made up of an ip address and port combination, you should use the same socket throughout your communication of the sever. This is because if you don't, it's possible you could get assigned a different port next time you change the underlying socket.
It is possible to loose UPD connectivity e.g. either of the endpoints in the connection is lost, say I go to the server and pull the plug?
EDIT2:Dan Bryant makes an excellent point in the comments, that links in with what I was saying about.
这篇关于关于C#UDP套接字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!