What local interface was connected or received?

  • When I receive a packet on an unconnected UDP socket bound to 0.0.0.0/ INADDR_ANY, how can I determine which local IP address it was sent to?
  • Can I determine on which interface it was received?
  • Can this also be done for connection oriented sockets such as TCP?

Update0

  • The platform is Linux, so the language does not matter, but C is native.
  • UDP sockets are host bound INADDR_ANY, so getsockname()returns 0.0.0.0.
+3
source share
2 answers

, . , , , , Linux/Unix. ?

+1

Windows. , getsockname() , .

+1

All Articles