From ac1f2aaadd927e8187edabaea9a788425bb42b9f Mon Sep 17 00:00:00 2001 From: Test_User Date: Tue, 8 Aug 2023 22:46:35 -0400 Subject: Hopefully disconnect on its own when things break now --- main.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 0fdd429..6d29836 100644 --- a/main.c +++ b/main.c @@ -230,9 +230,18 @@ int main(void) { struct string full_msg = {malloc(0), 0}; while (1) { char data[512]; - pthread_mutex_unlock(&send_lock); - uint64_t new_len = RECV(data, sizeof(data)); - pthread_mutex_lock(&send_lock); + + char timeout; + uint64_t new_len; + while (1) { + pthread_mutex_unlock(&send_lock); + new_len = RECV(data, sizeof(data), &timeout); + pthread_mutex_lock(&send_lock); + if (!timeout) + break; + + SEND(STRING("")); + } if (new_len == 0) { WRITES(1, STRING("Disconnected.\n")); -- cgit v1.2.3