dhbaird / easywsclient

A short and sweet WebSocket client for C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"hostname_connect" funtion code bug

fenglaijun opened this issue · comments

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"
}
...