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

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -