]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/tcp.c
lavfi: allow audio filters to request a given number of samples.
[ffmpeg] / libavformat / tcp.c
index a6eeeb0d0f5137c45e8e1082382ad9bd55e6f6ed..e77e4c5231e1118a1b352864c4854575050ce249 100644 (file)
@@ -28,7 +28,6 @@
 #if HAVE_POLL_H
 #include <poll.h>
 #endif
-#include <sys/time.h>
 
 typedef struct TCPContext {
     int fd;
@@ -90,7 +89,11 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
             ret = ff_neterrno();
             goto fail1;
         }
-        listen(fd, 1);
+        ret = listen(fd, 1);
+        if (ret) {
+            ret = ff_neterrno();
+            goto fail1;
+        }
         fd1 = accept(fd, NULL, NULL);
         if (fd1 < 0) {
             ret = ff_neterrno();
@@ -135,12 +138,15 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
         }
         /* test error */
         optlen = sizeof(ret);
-        getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen);
+        if (getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen))
+            ret = AVUNERROR(ff_neterrno());
         if (ret != 0) {
+            char errbuf[100];
+            ret = AVERROR(ret);
+            av_strerror(ret, errbuf, sizeof(errbuf));
             av_log(h, AV_LOG_ERROR,
                    "TCP connection to %s:%d failed: %s\n",
-                   hostname, port, strerror(ret));
-            ret = AVERROR(ret);
+                   hostname, port, errbuf);
             goto fail;
         }
     }