Archived
1
0
Fork 0

🐛 Close server when client leaves

This commit is contained in:
Simon V. Lejel 2024-02-10 14:40:58 +01:00
parent cfb7478ab9
commit 7a59e1ce77
Signed by: sl
GPG key ID: 6544A0430A2CFFAD

View file

@ -1,4 +1,5 @@
#include <arpa/inet.h>
#include <cstring>
#include <iostream>
#include <netinet/in.h>
#include <ostream>
@ -39,6 +40,12 @@ int main() {
while (true) {
char buffer[1024] = {0};
recv(clientSocket, buffer, sizeof(buffer), 0);
if (strlen(buffer) <= 0) {
cout << "Client seems to have just straight up left :(" << endl;
break;
}
cout << buffer << endl;
}