2

Say, I bind 0.0.0.0 port X, listen on it, and then accept new connection.

How can my server find destination IP address the client used to connect to?

Also, via which interface (assuming multihomed server) the SYN arrived?

4

1 回答 1

2

getsockname()对返回的套接字的调用accept()将为您提供连接的本地端的地址。

确定接口的最佳方法可能只是将本地 IP 地址getsockname()与接口地址进行匹配。

于 2013-07-04T14:36:40.103 回答