diff options
Diffstat (limited to 'client.c')
-rw-r--r-- | client.c | 38 |
1 files changed, 38 insertions, 0 deletions
@@ -136,6 +136,9 @@ int main(int argc, char *argv[]) perror("recv"); exit(1); } + + + printf("reply_type: %d\n", reply_type); if (reply_type == 2) { // we have a welcome message close(sockfd); @@ -191,6 +194,27 @@ int main(int argc, char *argv[]) close(sockfd); exit(1); } + else if (reply_type == 6) { // we station info + // get the string size + uint8_t string_size = -1; + if (recv(sockfd, &string_size, 1, 0) == -1) { + perror("recv"); + exit(1); + } + char *info = malloc(string_size); + if(info == NULL) { perror("malloc in info"); } + int bytes_to_read = string_size; + if (recv_all(sockfd, info, &bytes_to_read) == -1) { + perror("recv_all"); + exit(1); + } + // remove_timeout(sockfd); + fflush(stdout); + printf("Station Information:\n%s\n", info); + fflush(stdout); + free(info); + continue; + } printf("Lost connection to server. Exiting."); close(sockfd); @@ -214,6 +238,20 @@ void *command_line_routine(void* args) { printf("Exiting.\n"); close(sockfd); exit(0); + } + else if (strncmp("q\n", input, LINE_MAX) == 0) { + // end code if type in q + printf("Exiting.\n"); + close(sockfd); + exit(0); + } else if (strncmp("l\n", input, LINE_MAX) == 0) { + // send the command to list stations + // apply_timeout(sockfd); + int list_station_reply_type = 5; + if (send(sockfd, &list_station_reply_type, 1, 0) == -1) { + perror("send"); + exit(1); + } } else { // convert input to an int int inputInt = atoi(input); |