Mercurial > mplayer.hg
changeset 33921:6c1d39323b6e
Fix udp-slave on Windows: Make sure WSAStartup is called
before networking functions are used and fix inverted
set_blocking behaviour.
author | reimar |
---|---|
date | Wed, 24 Aug 2011 18:54:08 +0000 |
parents | 54c6c38fcaaa |
children | 25de7f7ee57c |
files | udp_sync.c |
diffstat | 1 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/udp_sync.c Tue Aug 23 20:04:40 2011 +0000 +++ b/udp_sync.c Wed Aug 24 18:54:08 2011 +0000 @@ -57,11 +57,23 @@ // how far off is still considered equal #define UDP_TIMING_TOLERANCE 0.02 +static void startup(void) +{ +#if HAVE_WINSOCK2_H + static int wsa_started; + if (!wsa_started) { + WSADATA wd; + WSAStartup(0x0202, &wd); + wsa_started = 1; + } +#endif +} + static void set_blocking(int fd, int blocking) { long sock_flags; #if HAVE_WINSOCK2_H - sock_flags = blocking; + sock_flags = !blocking; ioctlsocket(fd, FIONBIO, &sock_flags); #else sock_flags = fcntl(fd, F_GETFL, 0); @@ -86,6 +98,7 @@ struct timeval tv = { .tv_sec = 30 }; struct sockaddr_in servaddr = { 0 }; + startup(); sockfd = socket(AF_INET, SOCK_DGRAM, 0); if (sockfd == -1) return -1; @@ -133,6 +146,7 @@ static const int one = 1; int ip_valid = 0; + startup(); sockfd = socket(AF_INET, SOCK_DGRAM, 0); if (sockfd == -1) exit_player(EXIT_ERROR);