mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-15 09:18:27 +00:00
Fixed problem with is_socket_alive
This commit is contained in:
parent
4a9da530d3
commit
fb6c4cdfb4
1 changed files with 4 additions and 2 deletions
|
@ -2338,9 +2338,11 @@ inline bool wait_until_socket_is_ready(socket_t sock, time_t sec, time_t usec) {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool is_socket_alive(socket_t sock) {
|
inline bool is_socket_alive(socket_t sock) {
|
||||||
|
if (detail::select_read(sock, 0, 0) == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
char buf[1];
|
char buf[1];
|
||||||
return detail::select_read(sock, 0, 0) &&
|
return recv(sock, &buf[0], sizeof(buf), MSG_PEEK) > 0;
|
||||||
recv(sock, &buf[0], sizeof(buf), MSG_PEEK) != 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class SocketStream : public Stream {
|
class SocketStream : public Stream {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue