diff options
author | bloodstalker <thabogre@gmail.com> | 2017-03-05 10:21:34 +0000 |
---|---|---|
committer | bloodstalker <thabogre@gmail.com> | 2017-03-05 10:21:34 +0000 |
commit | cf700d07879db7e7c7b25e0c062f9e4a265fdeb6 (patch) | |
tree | 51c969c390b73f79986e0aa3c85add83cb0adf54 | |
parent | now runs a command and returns the output, missing stderr (diff) | |
download | mutator-cf700d07879db7e7c7b25e0c062f9e4a265fdeb6.tar.gz mutator-cf700d07879db7e7c7b25e0c062f9e4a265fdeb6.zip |
the received message is no longer overwritten. things are displayed correctly.
-rw-r--r-- | daemon/mutatorclient.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/daemon/mutatorclient.c b/daemon/mutatorclient.c index dfc0ec4..5686783 100644 --- a/daemon/mutatorclient.c +++ b/daemon/mutatorclient.c @@ -55,7 +55,6 @@ int main(int argc, char *argv[]) perror("connect failed.error."); return 1; } - puts("connected."); /*keep communicating with the server.*/ @@ -64,18 +63,29 @@ int main(int argc, char *argv[]) printf("enter massage: "); /*@DEVI-should later do something about reading from stdin*/ - if (fgets(message, 2000, stdin) == NULL) + if (fgets(message, 4000, stdin) == NULL) { puts("could not read from stdin"); } puts("read from stdin."); + if (strncmp(message, "end_comm", 8) == 0) + { + puts("client terminated."); + break; + } + /*send some data*/ if (send(sock, message, strlen(message), 0) < 0) { puts("send fialed."); return 1; } + puts("message sent."); + puts(message); + + sleep(1); + fflush(stdin); /*recieve a reply from the server*/ if (recv(sock, server_reply, 2000, 0) < 0) @@ -87,12 +97,12 @@ int main(int argc, char *argv[]) puts("server reply: "); puts(server_reply); -#if 0 - if (strncmp(server_reply, "end_comm", strlen(server_reply))) + for (int i = 0; i < 2000; ++i) { - break; + server_reply[i] = 0; } -#endif + + fflush(stdout); } close(sock); |