summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2022-12-04 14:02:21 +0100
committerxengineering <me@xengineering.eu>2022-12-04 14:02:21 +0100
commit9e2a44364bfae9a226e02fe7ddad032b16a1318f (patch)
tree63bad7db9e3c69e54985984da3b2f01e1931d946
parentd84ad1e1d7dc8dde2a0731c639d0ef3dd56cb72d (diff)
downloadlimox-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.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/xmpp.c b/xmpp.c
index 1546cdc..c574ba5 100644
--- a/xmpp.c
+++ b/xmpp.c
@@ -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);
+ }
+ }
}