diff --git a/src/cli.c b/src/cli.c index 88ac647..06ba02e 100644 --- a/src/cli.c +++ b/src/cli.c @@ -26,48 +26,49 @@ #include #include -#define BUFFERSIZE 80 +#define SEND_BUFFER_SIZE 80 +#define RECEIVE_BUFFER_SIZE 80 #define SERVER_IP_ADDR "127.0.0.1" #define SERVER_PORT 9000 void connectedCommunication(int sockfd) { - char buff[BUFFERSIZE], curChar; + char sendBuff[SEND_BUFFER_SIZE], receiveBuff[RECEIVE_BUFFER_SIZE], curChar; char *exitCommand = "exit"; int i; for (;;) { // Zeroing buffer - bzero(buff, sizeof(buff)); + bzero(sendBuff, sizeof(buff)); printf("\ngem-graph console> "); i = 0; // Read command from terminal while (( curChar= getchar()) != '\n') - buff[i++] = curChar; + sendBuff[i++] = curChar; // Check null-sized string - if (buff[0] == 0) { + if (sendBuff[0] == 0) { continue; } // Quit if asked - if (strcmp(exitCommand, buff) == 0) { + if (strcmp(exitCommand, sendBuff) == 0) { return; } // Otherwise send command to server - write(sockfd, buff, sizeof(buff)); + write(sockfd, sendBuff, sizeof(sendBuff)); // Zeroing buffer - bzero(buff, sizeof(buff)); + bzero(receiveBuff, sizeof(receiveBuff)); // Reading server answer - read(sockfd, buff, sizeof(buff)); + read(sockfd, receiveBuff, sizeof(receiveBuff)); - printf("%s\n", buff); + printf("%s\n", receiveBuff); } }