I am currently performing the following steps to listen on any available port on all interfaces:
struct addrinfo hints, *res;
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE;
if (getaddrinfo(NULL, "0", &hints, &res) != 0) {
cerr << "Couldn't getaddrinfo." << endl;
exit(-1);
}
I would like to dynamically communicate with only one interface, without a loopback system interface.
How can I do it?
Ben s source
share