fix: No longer hangs when socket closes/disconnects

This commit is contained in:
Tristan Russell 2025-01-17 17:59:13 -05:00
parent 87ab7cbcb1
commit 45378a6df7
1 changed files with 3 additions and 1 deletions

4
main.c
View File

@ -49,8 +49,9 @@ int StartEnv(int port) {
bytes_received = recv(client_sock, buffer, sizeof(buffer), 0);
if(bytes_received < 0) {
printf("Receive Error: %s (%d)\n", strerror(errno), errno);
break;
} else if(bytes_received == 0) {
continue;
break;
}
if(buffer[0] == 0x0) { // Step
@ -80,6 +81,7 @@ int StartEnv(int port) {
}
shutdown(client_sock, SHUT_RDWR);
close(client_sock);
return 0;
}
int main(int argc, char* argv[]) {