dhbaird / easywsclient

A short and sweet WebSocket client for C++
MIT License
741 stars 205 forks source link

"hostname_connect" funtion code bug #103

Open fenglaijun opened 1 year ago

fenglaijun commented 1 year ago

return error,should return "INVALID_SOCKET" ... socket_t hostname_connect(const std::string& hostname, int port) { struct addrinfo hints; struct addrinfo result; struct addrinfo p; int ret; socket_t sockfd = INVALID_SOCKET; char sport[16]; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; snprintf(sport, 16, "%d", port); if ((ret = getaddrinfo(hostname.c_str(), sport, &hints, &result)) != 0) { fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(ret)); return 1; //here should return "INVALID_SOCKET" } ...