43 #define OFFSET(x) offsetof(TCPContext, x)
44 #define D AV_OPT_FLAG_DECODING_PARAM
45 #define E AV_OPT_FLAG_ENCODING_PARAM
47 {
"listen",
"Listen for incoming connections",
OFFSET(listen),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, .flags =
D|
E },
48 {
"timeout",
"set timeout (in microseconds) of socket I/O operations",
OFFSET(rw_timeout),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags =
D|
E },
49 {
"listen_timeout",
"Connection awaiting timeout",
OFFSET(listen_timeout),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags =
D|
E },
63 struct addrinfo hints = { 0 }, *ai, *cur_ai;
69 char hostname[1024],proto[1024],path[1024];
73 av_url_split(proto,
sizeof(proto), NULL, 0, hostname,
sizeof(hostname),
74 &port, path,
sizeof(path), uri);
75 if (strcmp(proto,
"tcp"))
77 if (port <= 0 || port >= 65536) {
85 s->
listen = strtol(buf, &endptr, 10);
103 snprintf(portstr,
sizeof(portstr),
"%d", port);
112 "Failed to resolve hostname %s: %s\n",
122 cur_ai->ai_protocol);
151 if (cur_ai->ai_next) {
153 cur_ai = cur_ai->ai_next;
176 ret = recv(s->
fd, buf, size, 0);
207 return shutdown(s->
fd, how);
233 .priv_data_class = &tcp_class,