[英]Receiveing using Datagram socket in C
Since UDP is connectionless, is it possible for a single UDP socket/port on a client to receive packets from different servers(connections)? 由于UDP是无连接的,客户端上的单个UDP套接字/端口是否可以接收来自不同服务器(连接)的数据包? Or would it need separate connections to receive from each server?
或者它需要从每个服务器接收单独的连接?
I am designing a client which receives packets from 5 servers using UDP. 我正在设计一个客户端,它使用UDP从5台服务器接收数据包。 Does this require me to create 5 sockets each on different ports on my client?
这是否要求我在客户端的不同端口上创建5个套接字? Or can i receive data using a single port/socket at my client?
或者我可以在客户端使用单个端口/套接字接收数据吗?
Any help would be appreciated. 任何帮助,将不胜感激。 Thanks!
谢谢!
You can send and receive datagrams from multiple clients at the same time. 您可以同时从多个客户端发送和接收数据报。 for this you'd use
sendto()
and recvfrom()
. 为此你要使用
sendto()
和recvfrom()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.