Improve err handling in pubsub example

PUBLISHED_FROM=7660e252e1ac84bf2245718c548fb00288ff4e47
This commit is contained in:
Dmitry Frank 2018-01-30 20:31:16 +02:00 committed by Cesanta Bot
parent e5b3b8ad32
commit bd15ad4301

View File

@ -23,7 +23,9 @@ static void *stdin_thread(void *param) {
// Forward all types characters to the socketpair
while ((ch = getchar()) != EOF) {
unsigned char c = (unsigned char) ch;
send(sock, (const char *) &c, 1, 0);
if (send(sock, (const char *) &c, 1, 0) < 0) {
fprintf(stderr, "Failed to send byte to the socket");
}
}
return NULL;
}