diff options
author | xengineering <me@xengineering.eu> | 2022-12-04 14:02:21 +0100 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2022-12-04 14:02:21 +0100 |
commit | 9e2a44364bfae9a226e02fe7ddad032b16a1318f (patch) | |
tree | 63bad7db9e3c69e54985984da3b2f01e1931d946 | |
parent | d84ad1e1d7dc8dde2a0731c639d0ef3dd56cb72d (diff) | |
download | limox-9e2a44364bfae9a226e02fe7ddad032b16a1318f.tar limox-9e2a44364bfae9a226e02fe7ddad032b16a1318f.tar.zst limox-9e2a44364bfae9a226e02fe7ddad032b16a1318f.zip |
Implement printing of server response
Sadly there is no way to stop LimoX after connection. This has to be
fixed by a commit implementing a better control flow between GUI and
network part of the program.
-rw-r--r-- | xmpp.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -20,7 +20,9 @@ #define _GNU_SOURCE #include <stdlib.h> #include <stdio.h> +#include <errno.h> #include <string.h> +#include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <arpa/inet.h> @@ -170,4 +172,19 @@ void xmpp_connect(void) return; } printf("Stream init sent.\n"); + + printf("This is the server response:\n"); + char buf; + while(1) { + int retval = recv(sock, (void *)&buf, 1, 0); + if (retval == 0) { + printf("Connection closed!\n"); + break; + } else if (retval == 1) { + write(1, (const void *)&buf, 1); + } else { + printf(strerror(errno)); + printf("Unhandled recv() return value %d!\n", retval); + } + } } |