Ticket #1811: tcp.patch
| File tcp.patch, 3.1 KB (added by , 16 years ago) |
|---|
-
stream/tcp.c
53 53 54 54 /* IPv6 options */ 55 55 int network_prefer_ipv4 = 0; 56 int recv_timeout = -1; 57 int send_timeout = -1; 56 58 59 void 60 setSockTimeout(int socket_server_fd, int timeout, int send_recv_option) { 61 #if HAVE_WINSOCK2_H 62 int to; 63 #else 64 struct timeval to; 65 #endif 66 67 int cur_timeout = 10; 68 if(timeout > 0) 69 cur_timeout = timeout; 70 71 #if HAVE_WINSOCK2_H 72 /* timeout in milliseconds */ 73 to = cur_timeout * 1000; 74 75 #else 76 to.tv_sec = cur_timeout; 77 to.tv_usec = 0; 78 #endif 79 setsockopt(socket_server_fd, SOL_SOCKET, send_recv_option, &to, sizeof(to)); 80 } 81 57 82 // Converts an address family constant to a string 58 83 59 84 static const char *af2String(int af) { … … 94 119 95 120 #if HAVE_WINSOCK2_H 96 121 unsigned long val; 97 int to;98 #else99 struct timeval to;100 122 #endif 101 123 102 124 #if HAVE_WINSOCK2_H && defined(HAVE_AF_INET6) … … 116 138 } 117 139 118 140 #if defined(SO_RCVTIMEO) && defined(SO_SNDTIMEO) 119 #if HAVE_WINSOCK2_H 120 /* timeout in milliseconds */ 121 to = 10 * 1000; 122 #else 123 to.tv_sec = 10; 124 to.tv_usec = 0; 141 if(send_timeout != 0) 142 setSockTimeout(socket_server_fd, send_timeout, SO_RCVTIMEO); 143 144 if(recv_timeout != 0) 145 setSockTimeout(socket_server_fd, recv_timeout, SO_RCVTIMEO); 125 146 #endif 126 setsockopt(socket_server_fd, SOL_SOCKET, SO_RCVTIMEO, &to, sizeof(to));127 setsockopt(socket_server_fd, SOL_SOCKET, SO_SNDTIMEO, &to, sizeof(to));128 #endif129 147 130 148 switch (af) { 131 149 case AF_INET: our_s_addr = (void *) &server_address.four.sin_addr; break; -
stream/tcp.h
26 26 #define MPLAYER_TCP_H 27 27 28 28 extern int network_prefer_ipv4; 29 extern int send_timeout; 30 extern int recv_timeout; 29 31 30 32 /* Connect to a server using a TCP connection */ 31 33 int connect2Server (char *host, int port, int verb); -
DOCS/man/en/mplayer.1
1224 1224 .B \-udp\-slave 1225 1225 Listen on \-udp\-port and match the master's position. 1226 1226 . 1227 .TP 1228 .B \-send\-timeout <sec> 1229 Sets send timeout on tcp socket (default: 10). 1230 No timeout is set if sec = 0. 1227 1231 . 1232 .TP 1233 .B \-recv\-timeout <sec> 1234 Sets recv timeout on tcp socket (default: 10). 1235 No timeout is set if sec = 0. 1236 . 1237 . 1228 1238 .SH "DEMUXER/STREAM OPTIONS" 1229 1239 . 1230 1240 .TP -
cfg-mplayer.h
277 277 {"udp-ip", &udp_ip, CONF_TYPE_STRING, 0, 0, 1, NULL}, 278 278 {"udp-port", &udp_port, CONF_TYPE_INT, 0, 1, 65535, NULL}, 279 279 {"udp-seek-threshold", &udp_seek_threshold, CONF_TYPE_FLOAT, CONF_RANGE, 0.1, 100, NULL}, 280 {"send-timeout", &send_timeout, CONF_TYPE_INT, CONF_RANGE, 0, 10000, NULL}, 281 {"recv-timeout", &recv_timeout, CONF_TYPE_INT, CONF_RANGE, 0, 10000, NULL}, 280 282 #endif /* CONFIG_NETWORKING */ 281 283 282 284 // dump some stream out instead of playing the file
