🐛 Close server when client leaves
This commit is contained in:
parent
cfb7478ab9
commit
7a59e1ce77
1 changed files with 7 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue