#include "avformat.h"
#include <unistd.h>
#include "network.h"
+#include "os_support.h"
#include <sys/time.h>
typedef struct TCPContext {
if (!s)
return AVERROR(ENOMEM);
h->priv_data = s;
+ h->is_streamed = 1;
if (port <= 0 || port >= 65536)
goto fail;
+ if(!ff_network_init())
+ return AVERROR(EIO);
+
dest_addr.sin_family = AF_INET;
dest_addr.sin_port = htons(port);
if (resolve_host(&dest_addr.sin_addr, hostname) < 0)
if (ret < 0) {
if (ff_neterrno() == FF_NETERROR(EINTR))
goto redo;
- if (ff_neterrno() != FF_NETERROR(EINPROGRESS))
+ if (ff_neterrno() != FF_NETERROR(EINPROGRESS) &&
+ ff_neterrno() != FF_NETERROR(EAGAIN))
goto fail;
/* wait until we are connected or until abort */
return 0;
fail:
- ret = AVERROR_IO;
+ ret = AVERROR(EIO);
fail1:
if (fd >= 0)
closesocket(fd);
{
TCPContext *s = h->priv_data;
closesocket(s->fd);
+ ff_network_close();
av_free(s);
return 0;
}