diff options
author | sotech117 <michael_foiani@brown.edu> | 2023-09-23 18:50:23 -0400 |
---|---|---|
committer | sotech117 <michael_foiani@brown.edu> | 2023-09-23 18:50:23 -0400 |
commit | 5e3925610f1e9a1351c2b22cfa10b08385015b31 (patch) | |
tree | 17bd169b8c42a88cb7c4b4b74f1f7884207f7589 | |
parent | 8cdcbfc30301e65ecef8e8cc29fc67a5f05ada7d (diff) |
edits to control
-rw-r--r-- | client.c | 29 | ||||
-rwxr-xr-x | snowcast_control | bin | 26552 -> 35693 bytes | |||
-rw-r--r-- | snowcast_control.dSYM/Contents/Resources/DWARF/snowcast_control | bin | 15199 -> 14998 bytes | |||
-rwxr-xr-x | snowcast_listener | bin | 19120 -> 34654 bytes | |||
-rwxr-xr-x | snowcast_server | bin | 45184 -> 56748 bytes | |||
-rw-r--r-- | snowcast_server.dSYM/Contents/Resources/DWARF/snowcast_server | bin | 27811 -> 27786 bytes |
6 files changed, 14 insertions, 15 deletions
@@ -108,9 +108,6 @@ int main(int argc, char *argv[]) char input[LINE_MAX]; - fflush(stdout); - printf("Enter a number to change to it's station. Click q to end stream.\n"); - fflush(stdout); while (1) { char *line = fgets(input, LINE_MAX, stdin); @@ -145,7 +142,7 @@ void *reply_thread_routine(void* args) { // int recvbytes; while (1) { // recv the first byte of the message to get it's type - uint8_t reply_type = -1; + int reply_type; // print size of utin8 if (recv(sockfd, &reply_type, 1, 0) == -1) { perror("recv"); @@ -154,31 +151,33 @@ void *reply_thread_routine(void* args) { if (reply_type == 2) { // we have a welcome message // recv the message, check for errors too - char* num_stations = -1; + uint16_t buf_num_stations; int bytes_to_read = sizeof(uint16_t); - if (recv_all(sockfd, &num_stations, &bytes_to_read) == -1) { + if (recv_all(sockfd, &buf_num_stations, &bytes_to_read) == -1) { perror("recv_all"); exit(1); } - num_stations = ntohs((uint16_t) num_stations); + uint16_t num_stations = ntohs(buf_num_stations); fflush(stdout); - printf("Welcome to Snowcast! The server has %d stations.\n", num_stations); + printf("Click q to end stream.\n"); + printf("Welcome to Snowcast! The server has %u stations.\n", num_stations); fflush(stdout); continue; } if (reply_type == 3) { // we have an announce message // get the string size - u_int8_t string_size = -1; - if (recv(sockfd, &string_size, 1, 0) == -1) { + int string_size; + if (recv(sockfd, &string_size, 1, 0) == -1) + { perror("recv"); exit(1); } + char *song_name = malloc(string_size); if(song_name == NULL) { perror("malloc in song name"); } - int bytes_to_read = string_size; - if (recv_all(sockfd, song_name, &bytes_to_read) == -1) { + if (recv_all(sockfd, song_name, &string_size) == -1) { perror("recv_all"); exit(1); } @@ -187,15 +186,15 @@ void *reply_thread_routine(void* args) { continue; } else if (reply_type == 4) { // we have an invalid command message // get the string size - u_int8_t string_size = -1; + int string_size; if (recv(sockfd, &string_size, 1, 0) == -1) { perror("recv"); exit(1); } + char *message = malloc(string_size); if(message == NULL) { perror("malloc in message"); } - int bytes_to_read = string_size; - if (recv_all(sockfd, message, &bytes_to_read) == -1) { + if (recv_all(sockfd, message, &string_size) == -1) { perror("recv_all"); exit(1); } diff --git a/snowcast_control b/snowcast_control Binary files differindex f3549e3..8496be5 100755 --- a/snowcast_control +++ b/snowcast_control diff --git a/snowcast_control.dSYM/Contents/Resources/DWARF/snowcast_control b/snowcast_control.dSYM/Contents/Resources/DWARF/snowcast_control Binary files differindex 1b435c8..ca60b73 100644 --- a/snowcast_control.dSYM/Contents/Resources/DWARF/snowcast_control +++ b/snowcast_control.dSYM/Contents/Resources/DWARF/snowcast_control diff --git a/snowcast_listener b/snowcast_listener Binary files differindex 3e47e13..d399eb6 100755 --- a/snowcast_listener +++ b/snowcast_listener diff --git a/snowcast_server b/snowcast_server Binary files differindex 7897cb3..104d93f 100755 --- a/snowcast_server +++ b/snowcast_server diff --git a/snowcast_server.dSYM/Contents/Resources/DWARF/snowcast_server b/snowcast_server.dSYM/Contents/Resources/DWARF/snowcast_server Binary files differindex 787e279..2fb207a 100644 --- a/snowcast_server.dSYM/Contents/Resources/DWARF/snowcast_server +++ b/snowcast_server.dSYM/Contents/Resources/DWARF/snowcast_server |