This, I noticed, is due to the port. port is a C ++ string. When I hardcode the port number, say "4091", I do not see this problem. Any suggestions?
int sockfd;
struct addrinfo hints, *servinfo, *p;
int rv;
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_DGRAM;
hints.ai_flags = AI_PASSIVE;
cout << "port: " << port << endl;
const char * por = port.c_str();
if ((rv = getaddrinfo(NULL, por, &hints, &servinfo)) != 0) {
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
}
source
share