fpagliughi / sockpp

Modern C++ socket library.
BSD 3-Clause "New" or "Revised" License
769 stars 126 forks source link

How is it possible to check if a socket client is connected to the server on the server side #99

Open hannescam opened 1 week ago

hannescam commented 1 week ago

I want to find out if the current client is still connected to the server side (on the server side) but i couldn't find any way to do that I found out that with this sketchy code it works in some cases :

result = socket.read(buffer, sizeof(buffer));

if (result.error().value() == 0 && result.value() == 0) {
  // Runs most of the time when the client disconnects
}

socket is a sockpp::tcp_socket

Thanks for the help in advance