43 int listen_socket = 0;
49 char hostname[1024],proto[1024],path[1024];
53 &port, path,
sizeof(path), uri);
54 if (strcmp(proto,
"tcp") || port <= 0 || port >= 65536)
62 timeout = strtol(buf,
NULL, 10);
65 memset(&hints, 0,
sizeof(hints));
68 snprintf(portstr,
sizeof(portstr),
"%d", port);
72 "Failed to resolve hostname %s: %s\n",
100 struct pollfd p = {fd, POLLOUT, 0};
109 if (ret !=
AVERROR(EINPROGRESS) &&
119 ret = poll(&p, 1, 100);
128 optlen =
sizeof(ret);
129 getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen);
132 "TCP connection to %s:%d failed: %s\n",
133 hostname, port, strerror(ret));
168 ret = recv(s->
fd, buf, size, 0);
182 ret = send(s->
fd, buf, size, 0);
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
AVIOInterruptCB interrupt_callback
URLProtocol ff_tcp_protocol
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.
static int tcp_read(URLContext *h, uint8_t *buf, int size)
struct TCPContext TCPContext
void av_log(void *avcl, int level, const char *fmt,...)
static int tcp_close(URLContext *h)
int ff_socket_nonblock(int socket, int enable)
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
int ff_check_interrupt(AVIOInterruptCB *cb)
Check if the user has requested to interrup a blocking function associated with cb.
#define AVIO_FLAG_NONBLOCK
Use non-blocking mode.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
struct addrinfo * ai_next
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)
struct sockaddr * ai_addr