diff options
-rw-r--r-- | server.c | 19 | ||||
-rwxr-xr-x | snowcast_control | bin | 18848 -> 35277 bytes | |||
-rwxr-xr-x | snowcast_listener | bin | 13656 -> 34270 bytes | |||
-rwxr-xr-x | snowcast_server | bin | 37800 -> 71916 bytes |
4 files changed, 10 insertions, 9 deletions
@@ -380,7 +380,7 @@ void *print_info_routine(void *arg) { return (NULL); } -int send_all_udp(int udp_sockfd, char *buf, int *len, struct addrinfo *thread_res) +int send_all_udp(int udp_sockfd, char *buf, int *len, struct sockaddr *addr, socklen_t addrlen) { int MAX_PACKET_SIZE = 512; int total = 0; // how many bytes we've sent @@ -388,8 +388,7 @@ int send_all_udp(int udp_sockfd, char *buf, int *len, struct addrinfo *thread_re int n; while(total < *len) { - n = sendto(udp_sockfd, buf+total, MAX_PACKET_SIZE, 0, thread_res->ai_addr, thread_res->ai_addrlen); - // thread_res->ai_addr, thread_res->ai_addrlen)) == -1; + n = sendto(udp_sockfd, buf+total, MAX_PACKET_SIZE, 0, addr, addrlen); if (n == -1) { break; } total += n; bytesleft -= n; @@ -406,7 +405,7 @@ void udp_port_cleanup_handler(void *arg) close(sockfd); } -int setup_udp_connection(int udp_port, int *udp_sockfd, struct addrinfo* res) { +int setup_udp_connection(int udp_port, int *udp_sockfd, socklen_t *addrlen, struct sockaddr* addr) { // setup hints to get udp_port struct addrinfo thread_hints, *thread_res, *thread_servinfo; memset(&thread_hints, 0, sizeof thread_hints); @@ -447,8 +446,9 @@ int setup_udp_connection(int udp_port, int *udp_sockfd, struct addrinfo* res) { *udp_sockfd = sock; // only these two properties of addrinfo are needed to send udp - *res->ai_addr = *thread_res->ai_addr; - res->ai_addrlen = thread_res->ai_addrlen; + // TODO: FIX, or reroute somewhere else + *addrlen = thread_res->ai_addrlen; + *addr = *thread_res->ai_addr; return 1; } @@ -470,8 +470,9 @@ void *send_udp_packet_routine(void *arg) { // setup udp socket for this thread/user int udp_port = user_data[user_index].udpPort; int udp_sockfd; - struct addrinfo *res; - if (setup_udp_connection(udp_port, &udp_sockfd, &res) == -1){ + struct sockaddr addr; + socklen_t addrlen; + if (setup_udp_connection(udp_port, &udp_sockfd, &addrlen, &addr) == -1){ fprintf(stderr, "failure in setup_udp_connection"); return (NULL); // error occured } @@ -493,7 +494,7 @@ void *send_udp_packet_routine(void *arg) { } // send the data! (no error check since udp) - send_all_udp(udp_sockfd, file_buffer, &buffer_size, &res); + send_all_udp(udp_sockfd, file_buffer, &buffer_size, &addr, addrlen); // cleanup close(udp_sockfd); diff --git a/snowcast_control b/snowcast_control Binary files differindex 01f4d14..6eaeee5 100755 --- a/snowcast_control +++ b/snowcast_control diff --git a/snowcast_listener b/snowcast_listener Binary files differindex f27a5c1..d15c2ac 100755 --- a/snowcast_listener +++ b/snowcast_listener diff --git a/snowcast_server b/snowcast_server Binary files differindex 5c97922..86eb007 100755 --- a/snowcast_server +++ b/snowcast_server |