From: Ramakrishnan Muthukrishnan <ram@rkrishnan.org>
Date: Mon, 27 Nov 2023 17:51:03 +0000 (+0530)
Subject: rigctl tcp server: better connection error handling
X-Git-Url: https://git.rkrishnan.org/pf/content/simplejson/frontends/flags?a=commitdiff_plain;h=76532b13356c8390f920dc31c7f91b0b20fc3a1b;p=pihpsdr.git

rigctl tcp server: better connection error handling
---

diff --git a/rigctl.c b/rigctl.c
index 75ab172..087ea92 100644
--- a/rigctl.c
+++ b/rigctl.c
@@ -913,9 +913,13 @@ static gpointer rigctl_client(gpointer data) {
 		    command_index = 0;
 		}
 	    }
-	} else if (numbytes <= 0) {
+	} else if (numbytes == 0) {
 	    // print the errno string
-	    perror("RIGCTL server: got zero bytes from the client");
+	    perror("RIGCTL server: connection closed by the client");
+	    break;
+	} else if (numbytes == -1) {
+	    perror("RIGCTL server: error reading from the client");
+	    break;
 	}
     }