Re: UDP requires 2 reads to obtain vital information - Kindly comment

From: Andy Lutomirski
Date: Wed Aug 10 2011 - 13:49:49 EST


On 08/10/2011 12:57 PM, Sreeram B S wrote:
Respected people,
I am Sreeram. I work on TCP/IP network applications.
This mail is regarding UDP.
Whenever a UDP datagram arrives, the receiver may wish to know the
sender's IP address and also the destination address of that datagram.
The recvfrom() function will return the sender's IP address. If the
destination address of the datagram is required, then the user has to
set the IP_PKTINFO socket option for the UDP socket and get the
address as ancillary data in recvmsg(). So, the point here is that the
user has to issue 2 reads on the same datagram (with the flag MSG_PEEK
in first read call enabled) in order to obtain the sender's IP and the
destination IP of the datagram.

Does the msg_name field of struct msghdr not work?

--Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/