1
mirror of https://github.com/mpv-player/mpv synced 2024-11-14 22:48:35 +01:00

winsocks expects an int in milliseconds instead of struct timeval to set

the timeout of a socket

patch by Zuxy Meng, zuxy dot meng ... gmailcom



git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@22397 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
ivo 2007-03-01 14:57:44 +00:00
parent 3462da0b5c
commit 2477fdf577

View File

@ -77,6 +77,9 @@ connect2Server_with_af(char *host, int port, int af,int verb) {
#ifdef HAVE_WINSOCK2 #ifdef HAVE_WINSOCK2
u_long val; u_long val;
int to;
#else
struct timeval to;
#endif #endif
socket_server_fd = socket(af, SOCK_STREAM, 0); socket_server_fd = socket(af, SOCK_STREAM, 0);
@ -88,10 +91,15 @@ connect2Server_with_af(char *host, int port, int af,int verb) {
} }
#if defined(SO_RCVTIMEO) && defined(SO_SNDTIMEO) #if defined(SO_RCVTIMEO) && defined(SO_SNDTIMEO)
tv.tv_sec = 10; #ifdef HAVE_WINSOCK2
tv.tv_usec = 0; /* timeout in milliseconds */
setsockopt(socket_server_fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)); to = 10 * 1000;
setsockopt(socket_server_fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)); #else
to.tv_sec = 10;
to.tv_usec = 0;
#endif
setsockopt(socket_server_fd, SOL_SOCKET, SO_RCVTIMEO, &to, sizeof(to));
setsockopt(socket_server_fd, SOL_SOCKET, SO_SNDTIMEO, &to, sizeof(to));
#endif #endif
switch (af) { switch (af) {