diff options
-rwxr-xr-x | c | bin | 35150 -> 35294 bytes | |||
-rw-r--r-- | c.dSYM/Contents/Resources/DWARF/c | bin | 13761 -> 13866 bytes | |||
-rw-r--r-- | client.c | 15 | ||||
-rwxr-xr-x | l | bin | 34654 -> 34654 bytes | |||
-rwxr-xr-x | s | bin | 54494 -> 54654 bytes | |||
-rw-r--r-- | s.dSYM/Contents/Resources/DWARF/s | bin | 21128 -> 21196 bytes | |||
-rwxr-xr-x | snowcast_control | bin | 35165 -> 35309 bytes | |||
-rw-r--r-- | snowcast_control.dSYM/Contents/Resources/DWARF/snowcast_control | bin | 13761 -> 13866 bytes | |||
-rwxr-xr-x | snowcast_server | bin | 35116 -> 35116 bytes | |||
-rw-r--r-- | snowcast_server_concurrent.c | 42 |
10 files changed, 37 insertions, 20 deletions
Binary files differ diff --git a/c.dSYM/Contents/Resources/DWARF/c b/c.dSYM/Contents/Resources/DWARF/c Binary files differindex 7af6442..785b2db 100644 --- a/c.dSYM/Contents/Resources/DWARF/c +++ b/c.dSYM/Contents/Resources/DWARF/c @@ -158,13 +158,24 @@ void *reply_thread_routine(void* args) { for (int i = 0; i < recvbytes; i++) { printf("%c ", buf[i]); } - struct Reply reply; - memcpy(&reply, buf, sizeof(struct Reply)); + memcpy(&reply, buf, 2); + + // print out the fields of reply on one line + printf("\nclient: replyType: %d, stringSize: %d\n", reply.replyType, reply.stringSize); + // print the size of reply if (reply.replyType == 3) { printf("client: received an announce message\n"); + char *song_name = malloc(reply.stringSize); + // printf(sizeof(struct Reply)); + memcpy(song_name, buf + 2, reply.stringSize); + + printf("client: song name: %s\n", song_name); + + free(song_name); + continue; } else if (reply.replyType == 4) { printf("client: received an invalid command message\n"); Binary files differBinary files differdiff --git a/s.dSYM/Contents/Resources/DWARF/s b/s.dSYM/Contents/Resources/DWARF/s Binary files differindex feff9cb..74f9ec9 100644 --- a/s.dSYM/Contents/Resources/DWARF/s +++ b/s.dSYM/Contents/Resources/DWARF/s diff --git a/snowcast_control b/snowcast_control Binary files differindex 1ab5778..fa08142 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 76fce35..774ea29 100644 --- a/snowcast_control.dSYM/Contents/Resources/DWARF/snowcast_control +++ b/snowcast_control.dSYM/Contents/Resources/DWARF/snowcast_control diff --git a/snowcast_server b/snowcast_server Binary files differindex 444d321..c194134 100755 --- a/snowcast_server +++ b/snowcast_server diff --git a/snowcast_server_concurrent.c b/snowcast_server_concurrent.c index 110792d..03d6414 100644 --- a/snowcast_server_concurrent.c +++ b/snowcast_server_concurrent.c @@ -59,6 +59,8 @@ void *update_user_station(int sockfd, int stationNum); void *print_user_data(int sockfd); void destroy_user(int sockfd); +void send_announce_message(int fd, int station_num); + // void *load_file(void* arg); @@ -379,24 +381,7 @@ void *select_thread(void *arg) { // update station of user update_user_station(i, ntohs(command.number)); - char* file_path = station_data[station_num].filePath; - int len_file_path = strlen(file_path); - - char *send_buffer = malloc(len_file_path+2); - send_buffer[0] = 3; - send_buffer[1] = len_file_path; - - memcpy(send_buffer + 2, file_path, len_file_path); - - printf("buffer: %s\n", send_buffer); - - int bytessent; - if ((bytessent = send(newfd, send_buffer, len_file_path + 2, 0)) == -1) - perror("send"); - // print the number of bytes sent - printf("sent %d bytes\n", bytessent); - - free(send_buffer); + send_announce_message(i, station_num); } else { // send back in invalid command @@ -486,4 +471,25 @@ void *get_in_addr(struct sockaddr *sa) } return &(((struct sockaddr_in6*)sa)->sin6_addr); +} + +void send_announce_message(int fd, int station_num) { + char* file_path = station_data[station_num].filePath; + int len_file_path = strlen(file_path); + + char *send_buffer = malloc(len_file_path+2); + send_buffer[0] = 3; + send_buffer[1] = len_file_path; + + memcpy(send_buffer + 2, file_path, len_file_path); + + printf("buffer: %s\n", send_buffer); + + int bytessent; + if ((bytessent = send(fd, send_buffer, len_file_path + 2, 0)) == -1) + perror("send"); + // print the number of bytes sent + printf("sent %d bytes\n", bytessent); + + free(send_buffer); }
\ No newline at end of file |