diff options
author | 2007-02-04 14:18:56 +0000 | |
---|---|---|
committer | 2007-02-04 14:18:56 +0000 | |
commit | 288f3e1a138fe380f5758d47bc399aac46028870 (patch) | |
tree | 5f4f9c7b805be15e65ac37c9a21c422a8a3786de /stream | |
parent | 7a66e827a13e78d4fa4469906c860f533067b393 (diff) |
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
Diffstat (limited to 'stream')
-rw-r--r-- | stream/tcp.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/stream/tcp.c b/stream/tcp.c index c9ffc89b47..425598465e 100644 --- a/stream/tcp.c +++ b/stream/tcp.c @@ -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 |