Changeset 4759:10a753806fd5 in roaraudio
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r4756 r4759 6 6 * Added time display to roarvorbis (Closes: #102) 7 7 * Added support to roarshout to read password form user or file (Closes: #101) 8 * Added IPv6 support 8 9 9 10 v. 0.4beta3 - Wed Jan 26 2011 23:26 CET -
configure
r4751 r4759 1494 1494 test_func_defmake ROAR_HAVE_GETSOCKOPT getsockopt 'getsockopt(0, 0, 0, (void*)0, (void*)0)' -- sys/types.h sys/socket.h 1495 1495 test_func_defmake ROAR_HAVE_SETSOCKOPT setsockopt 'setsockopt(0, 0, 0, (void*)0, (void*)0)' -- sys/types.h sys/socket.h 1496 test_func_defmake ROAR_HAVE_GETADDRINFO getaddrinfo 'getaddrinfo((void*)0, (void*)0, (void*)0, (void**)0)' -- sys/types.h sys/socket.h netdb.h 1496 1497 test_func_defmake ROAR_HAVE_RAND rand 'rand()' -- stdlib.h 1497 1498 test_func_defmake ROAR_HAVE_RAND_R rand_r 'rand_r((unsigned int*)0)' -- stdlib.h -
libroar/socket.c
r4708 r4759 512 512 #endif 513 513 } socket_addr; 514 socklen_t addrlen; 514 515 #endif 515 516 #if defined(ROAR_HAVE_IPV4) || defined(ROAR_HAVE_IPV6) … … 529 530 char * del; 530 531 #endif 532 int af_guessed = 0; 533 #ifdef ROAR_HAVE_GETADDRINFO 534 struct addrinfo hints, *res = NULL; 535 char port_as_string[32]; 536 #endif 531 537 532 538 ROAR_DBG("roar_socket_open(mode=%i, type=%i, host='%s', port=%i) = ?", mode, type, host, port); … … 536 542 537 543 if ( type == ROAR_SOCKET_TYPE_UNKNOWN ) { 544 af_guessed = 1; 538 545 type = ROAR_SOCKET_TYPE_INET; 539 546 if ( *host == '/' ) { … … 614 621 ROAR_DBG("roar_socket_open(*): type=INET|INET6, host='%s', port=%i", host, port); 615 622 623 #ifdef ROAR_HAVE_GETADDRINFO 624 memset(&hints, 0, sizeof(hints)); 625 hints.ai_socktype = SOCK_STREAM; 626 if ( af_guessed ) { 627 hints.ai_family = AF_UNSPEC; 628 } else { 629 hints.ai_family = type == ROAR_SOCKET_TYPE_INET ? AF_INET : AF_INET6; 630 } 631 632 snprintf(port_as_string, sizeof(port_as_string), "%i", port); 633 634 if ( getaddrinfo(host, port_as_string, &hints, &res) != 0 ) 635 return -1; 636 637 if ( af_guessed ) { 638 type = res->ai_family == AF_INET ? ROAR_SOCKET_TYPE_INET : ROAR_SOCKET_TYPE_INET6; 639 } 640 641 if ( type == ROAR_SOCKET_TYPE_INET ) { 642 fh = roar_socket_new_tcp(); 643 } else { 644 fh = roar_socket_new_tcp6(); 645 } 646 647 memcpy(&(socket_addr.sa), res->ai_addr, res->ai_addrlen); 648 addrlen = res->ai_addrlen; 649 650 if ( res != NULL ) 651 freeaddrinfo(res); 652 #else 616 653 if ( (he = gethostbyname(host)) == NULL ) { 617 654 ROAR_ERR("roar_socket_open(*): Can\'t resolve host name '%s'", … … 622 659 ROAR_DBG("roar_socket_open(*): he=%p", he); 623 660 624 memcpy((struct in_addr *)& socket_addr.in.sin_addr, he->h_addr, sizeof(struct in_addr));661 memcpy((struct in_addr *)&(socket_addr.in.sin_addr), he->h_addr, sizeof(struct in_addr)); 625 662 626 663 /* set the connect information */ … … 629 666 630 667 fh = roar_socket_new_tcp(); 668 addrlen = sizeof(struct sockaddr_in); 669 #endif 631 670 632 671 ROAR_DBG("roar_socket_open(*): fh=%i", fh); … … 641 680 ROAR_DBG("roar_socket_open(*): fh=%i", fh); 642 681 643 if ( mode_func(fh, (struct sockaddr *)&socket_addr. in, sizeof(struct sockaddr_in)) == -1 ) {682 if ( mode_func(fh, (struct sockaddr *)&socket_addr.sa, addrlen) == -1 ) { 644 683 ROAR_DBG("roar_socket_open(*): Can not connect/bind: %s", strerror(errno)); 645 684 close(fh);
Note: See TracChangeset
for help on using the changeset viewer.