I'm trying to send commands using UDP. The receiver is supposed to receive the UDP datagram and reply. However, I would like the reply to always be sent to the sender's source port. I know how to parse the the port (struct header and move the pointer to the right position...), however, I'm looking for a function that returns the whole received frame including the headers and not only the datagram/data.
What about the recvfrom()
function? It allows you to grab the data and it fills a sockaddr
struct from which you can find the source port of the sender.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.