22 #include "libavutil/parseutils.h"
38 struct addrinfo hints = { 0 }, *ai, *cur_ai;
41 int listen_socket = 0;
45 int timeout = 100, listen_timeout = -1;
46 char hostname[1024],proto[1024],path[1024];
50 &port, path,
sizeof(path), uri);
51 if (strcmp(proto,
"tcp"))
53 if (port <= 0 || port >= 65536) {
62 timeout = strtol(buf,
NULL, 10);
65 listen_timeout = strtol(buf,
NULL, 10);
70 snprintf(portstr,
sizeof(portstr),
"%d", port);
79 "Failed to resolve hostname %s: %s\n",
97 listen_timeout, h)) < 0) {
103 timeout * 100, h, !!cur_ai->ai_next)) < 0) {
118 if (cur_ai->ai_next) {
120 cur_ai = cur_ai->ai_next;
143 ret = recv(s->
fd, buf, size, 0);
157 ret = send(s->
fd, buf, size, 0);
174 return shutdown(s->
fd, how);
void av_url_split(char *proto, int proto_size, char *authorization, int authorization_size, char *hostname, int hostname_size, int *port_ptr, char *path, int path_size, const char *url)
Split a URL string into components.
#define URL_PROTOCOL_FLAG_NETWORK
static int tcp_open(URLContext *h, const char *uri, int flags)
int is_streamed
true if streamed (no seek possible), default = false
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
URLProtocol ff_tcp_protocol
int ff_socket(int af, int type, int proto)
int ff_listen_bind(int fd, const struct sockaddr *addr, socklen_t addrlen, int timeout, URLContext *h)
Bind to a file descriptor and poll for a connection.
miscellaneous OS support macros and functions.
int av_find_info_tag(char *arg, int arg_size, const char *tag1, const char *info)
Attempt to find a specific tag in a URL.
int ff_listen_connect(int fd, const struct sockaddr *addr, socklen_t addrlen, int timeout, URLContext *h, int will_try_next)
Connect to a file descriptor and poll for result.
static int tcp_read(URLContext *h, uint8_t *buf, int size)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int tcp_close(URLContext *h)
static int tcp_shutdown(URLContext *h, int flags)
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
static int tcp_write(URLContext *h, const uint8_t *buf, int size)
int ff_network_wait_fd(int fd, int write)
unbuffered private I/O API
static int tcp_get_file_handle(URLContext *h)