diff options
author | faust3 <faust3@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-06-18 14:31:10 +0000 |
---|---|---|
committer | faust3 <faust3@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-06-18 14:31:10 +0000 |
commit | 6bfc62a9b98833da2fc67b7b2bc0ce0dad95a45c (patch) | |
tree | 22d85730e80dff9e2acd19fa92328134d3620c38 /libmpdemux/network.c | |
parent | c281648a95620a91c172f3c3399a44d5e3125dc0 (diff) |
calling bind with multicast addresses doesn't work on windows, patch by Martin Decky <deckm1am at ss1000.ms.mff.cuni.cz>
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@12611 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux/network.c')
-rw-r--r-- | libmpdemux/network.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/libmpdemux/network.c b/libmpdemux/network.c index 528af01590..7357615743 100644 --- a/libmpdemux/network.c +++ b/libmpdemux/network.c @@ -1080,6 +1080,7 @@ rtp_open_socket( URL_t *url ) { struct sockaddr_in server_address; struct ip_mreq mcast; struct timeval tv; + struct hostent *hp; mp_msg(MSGT_NETWORK,MSGL_V,"Listening for traffic on %s:%d ...\n", url->hostname, url->port ); @@ -1091,12 +1092,16 @@ rtp_open_socket( URL_t *url ) { } if( isalpha(url->hostname[0]) ) { - struct hostent *hp =(struct hostent*)gethostbyname( url->hostname ); +#ifndef HAVE_WINSOCK2 + hp =(struct hostent*)gethostbyname( url->hostname ); if( hp==NULL ) { mp_msg(MSGT_NETWORK,MSGL_ERR,"Counldn't resolve name: %s\n", url->hostname); return -1; } memcpy( (void*)&server_address.sin_addr.s_addr, (void*)hp->h_addr, hp->h_length ); +#else + server_address.sin_addr.s_addr = htonl(INADDR_ANY); +#endif } else { #ifndef HAVE_WINSOCK2 #ifdef USE_ATON @@ -1105,8 +1110,7 @@ rtp_open_socket( URL_t *url ) { inet_pton(AF_INET, url->hostname, &server_address.sin_addr); #endif #else - unsigned int addr = inet_addr(url->hostname); - memcpy( (void*)&server_address.sin_addr, (void*)&addr, sizeof(addr) ); + server_address.sin_addr.s_addr = htonl(INADDR_ANY); #endif } server_address.sin_family=AF_INET; @@ -1123,6 +1127,20 @@ rtp_open_socket( URL_t *url ) { return -1; } } + +#ifdef HAVE_WINSOCK2 + if (isalpha(url->hostname[0])) { + hp =(struct hostent*)gethostbyname( url->hostname ); + if( hp==NULL ) { + mp_msg(MSGT_NETWORK,MSGL_ERR,"Counldn't resolve name: %s\n", url->hostname); + return -1; + } + memcpy( (void*)&server_address.sin_addr.s_addr, (void*)hp->h_addr, hp->h_length ); + } else { + unsigned int addr = inet_addr(url->hostname); + memcpy( (void*)&server_address.sin_addr, (void*)&addr, sizeof(addr) ); + } +#endif // Increase the socket rx buffer size to maximum -- this is UDP rxsockbufsz = 240 * 1024; |