我可以使用2种不同的静态IP(IPv4)中的任何一种来访问我的网站。特定IP上的C开放套接字
是否可以打开到另一台服务器的TCP连接,指定要使用哪两个IP作为返回地址?
XXXX(我的服务器)=> ZZZZ(目的地服务器)
YYYY(我的服务器)=> ZZZZ在该示例(目的地服务器)
查错等已为简单起见缘故省略:
struct addrinfo hints, *result;
hints.ai_flags = 0;
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
hints.ai_addrlen = 0;
hints.ai_canonname = NULL;
hints.ai_addr = NULL;
hints.ai_next = NULL;
getaddrinfo(domain, "80", &hints, &result);
socket(result->ai_family, result->ai_socktype, result->ai_protocol);