C++ DGRAM socket get the RECEIVER address

后端 未结 2 451
走了就别回头了
走了就别回头了 2020-12-07 03:28

In C++,
how can I get the receiver address of the UDP packet which I have received using recvfrom. I know that it should be the same host on which I

2条回答
  •  旧时难觅i
    2020-12-07 04:24

    On Linux you want to use IP_PKTINFO option, see ip(7), and the recvmsg(2) call.

    Stevens has examples of doing this but with IP_RECVDSTADDR and IP_RECVIF options that are not available on Linux.

提交回复
热议问题