Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Say, I bind 0.0.0.0 port X, listen on it, and then accept new connection.
0.0.0.0
How can my server find destination IP address the client used to connect to?
Also, via which interface (assuming multihomed server) the SYN arrived?
getsockname()对返回的套接字的调用accept()将为您提供连接的本地端的地址。
getsockname()
accept()
确定接口的最佳方法可能只是将本地 IP 地址getsockname()与接口地址进行匹配。