1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-18 12:55:16 +00:00

Add timeout to tcp connections, avoid hanging forever.

Based on patch for bugzilla #673


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@22131 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
rtogni 2007-02-04 14:18:56 +00:00
parent 7a66e827a1
commit 288f3e1a13

View File

@ -86,6 +86,13 @@ connect2Server_with_af(char *host, int port, int af,int verb) {
return TCP_ERROR_FATAL;
}
#if defined SO_RCVTIMEO && defined SO_SNDTIMEO
tv.tv_sec = 10;
tv.tv_usec = 0;
setsockopt(socket_server_fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
setsockopt(socket_server_fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));
#endif
switch (af) {
case AF_INET: our_s_addr = (void *) &server_address.four.sin_addr; break;
#ifdef HAVE_AF_INET6