42 #define OFFSET(x) offsetof(TCPContext, x)
43 #define D AV_OPT_FLAG_DECODING_PARAM
44 #define E AV_OPT_FLAG_ENCODING_PARAM
47 {
"timeout",
"timeout of socket i/o operations",
OFFSET(rw_timeout),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX,
D|
E },
48 {
"listen_timeout",
"connection awaiting timeout",
OFFSET(listen_timeout),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX,
D|
E },
62 struct addrinfo hints = { 0 }, *ai, *cur_ai;
68 char hostname[1024],proto[1024],path[1024];
72 av_url_split(proto,
sizeof(proto), NULL, 0, hostname,
sizeof(hostname),
73 &port, path,
sizeof(path), uri);
74 if (strcmp(proto,
"tcp"))
76 if (port <= 0 || port >= 65536) {
97 snprintf(portstr,
sizeof(portstr),
"%d", port);
106 "Failed to resolve hostname %s: %s\n",
114 fd = socket(cur_ai->ai_family, cur_ai->ai_socktype, cur_ai->ai_protocol);
143 if (cur_ai->ai_next) {
145 cur_ai = cur_ai->ai_next;
168 ret = recv(s->
fd, buf, size, 0);
182 ret = send(s->
fd, buf, size, 0);
199 return shutdown(s->
fd, how);
224 .priv_data_class = &tcp_context_class,