diff --git a/libavformat/network.h b/libavformat/network.h index 6ceba41902..723b4f9536 100644 --- a/libavformat/network.h +++ b/libavformat/network.h @@ -21,16 +21,26 @@ #ifndef NETWORK_H #define NETWORK_H +#ifdef __MINGW32__ +#include +#include + +#define ff_neterrno() WSAGetLastError() +#define FF_NETERROR(err) WSA##err +#define WSAEAGAIN WSAEWOULDBLOCK +#else #include #include #include -#ifdef HAVE_ARPA_INET_H -#include -#endif #include #define ff_neterrno() errno #define FF_NETERROR(err) err +#endif + +#ifdef HAVE_ARPA_INET_H +#include +#endif int ff_socket_nonblock(int socket, int enable); diff --git a/libavformat/os_support.c b/libavformat/os_support.c index abee749aac..bcb62b8528 100644 --- a/libavformat/os_support.c +++ b/libavformat/os_support.c @@ -117,10 +117,14 @@ int resolve_host(struct in_addr *sin_addr, const char *hostname) int ff_socket_nonblock(int socket, int enable) { +#ifdef __MINGW32__ + return ioctlsocket(socket, FIONBIO, &enable); +#else if (enable) return fcntl(socket, F_SETFL, fcntl(socket, F_GETFL) | O_NONBLOCK); else return fcntl(socket, F_SETFL, fcntl(socket, F_GETFL) & ~O_NONBLOCK); +#endif } #endif /* CONFIG_NETWORK */