Skip to content

Commit

Permalink
Fix CanConnect for web sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
nico-abram committed Jun 30, 2018
1 parent 2d86c8e commit 02b7875
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/ezsockets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,13 @@ bool EzSockets::CanConnect(const std::string& host, unsigned short port)
FD_ZERO(&readfds);
FD_SET(sock.sock, &readfds);
auto read = select(sock.sock + 1, nullptr, &readfds, nullptr, &(sock.timeout));
bool select = read > -1 && write > -1;
if (!select) {
sock.close();
return false;
}
bool err = sock.IsError() || !sock.CanRead() || !sock.CanWrite();
FD_ZERO(&readfds);
FD_SET(sock.sock, &readfds);
auto exc = select(sock.sock + 1, nullptr, nullptr, &readfds, &(sock.timeout));
bool select = read > -1 && write > -1 && exc > -1;
auto err = sock.IsError() || !sock.CanWrite();
sock.close();
return !err;
return select && !err;
}

bool EzSockets::setAddr(const std::string& host, unsigned short port)
Expand Down

0 comments on commit 02b7875

Please sign in to comment.