I am currently writing a small UDP socket library for personal use, but I have not been able to find documentation on this.
I mean ssize_t recvfrom(int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen);, from the POSIX header <sys/socket.h>.
I want to reuse the structure src_addrthat I pass recvfrom to use with sendto(the same header), regardless of whether it is running recvfromor not. If successful, it will contain the address of the partner sending its data (there is only one in my use case), which is the intended behavior; however, it generates an error EAGAINwhen a non-blocking read is not performed, and the state is src_addrthen unclear. If src_addrnot changed, it will still contain the destination address and can be reused, but if it does, then I will have to use a temporary variable.
source
share