#ifndef AVFORMAT_NETWORK_H
#define AVFORMAT_NETWORK_H
+#include <errno.h>
+
#include "config.h"
+#include "libavutil/error.h"
+#include "os_support.h"
#if HAVE_WINSOCK2_H
#include <winsock2.h>
#define ECONNREFUSED WSAECONNREFUSED
#define EINPROGRESS WSAEINPROGRESS
-static inline int ff_neterrno() {
+static inline int ff_neterrno(void)
+{
int err = WSAGetLastError();
switch (err) {
case WSAEWOULDBLOCK:
#include <arpa/inet.h>
#endif
+#if HAVE_POLL_H
+#include <poll.h>
+#endif
+
int ff_socket_nonblock(int socket, int enable);
static inline int ff_network_init(void)
return 1;
}
+static inline int ff_network_wait_fd(int fd, int write)
+{
+ int ev = write ? POLLOUT : POLLIN;
+ struct pollfd p = { .fd = fd, .events = ev, .revents = 0 };
+ int ret;
+ ret = poll(&p, 1, 100);
+ return ret < 0 ? ff_neterrno() : p.revents & (ev | POLLERR | POLLHUP) ? 0 : AVERROR(EAGAIN);
+}
+
static inline void ff_network_close(void)
{
#if HAVE_WINSOCK2_H