c - getaddrinfo error: ai_socktype not supported -
struct addrinfo *myaddrinfo, *curmyaddrinfo, hint; memset(&hint, 0, sizeof(struct addrinfo)); hint.ai_family = af_inet; hint.ai_protocol = ai_passive; hint.ai_socktype = sock_stream; const int code = getaddrinfo(null, server_port, &hint, &myaddrinfo); if ((code) != 0) { printf("getaddrinfo error occours: %s ", gai_strerror(code)); return 1; }
this gives error: "ai_socktype not supported" if comment out hint.ai_protocol = ai_passive;
through, wondering why happens?
thanks time
that's because ai_passive referred ai_flags field, (not ai_protocol). try :
hint.ai_flags = ai_passive;
and have @ addrinfo structure.
Comments
Post a Comment