changeset 6378:a5b3f5d68db6 libavformat

Print error messages in case of connection failure or name resolution failure in tcp.c.
author rbultje
date Sat, 14 Aug 2010 20:34:51 +0000
parents 7eafa931f4e4
children 0bcd6a8bc5d5
files tcp.c
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/tcp.c	Fri Aug 13 20:06:18 2010 +0000
+++ b/tcp.c	Sat Aug 14 20:34:51 2010 +0000
@@ -54,8 +54,13 @@
     hints.ai_family = AF_UNSPEC;
     hints.ai_socktype = SOCK_STREAM;
     snprintf(portstr, sizeof(portstr), "%d", port);
-    if (getaddrinfo(hostname, portstr, &hints, &ai))
+    ret = getaddrinfo(hostname, portstr, &hints, &ai);
+    if (ret) {
+        av_log(NULL, AV_LOG_ERROR,
+               "Failed to resolve hostname %s: %s\n",
+               hostname, gai_strerror(ret));
         return AVERROR(EIO);
+    }
 
     cur_ai = ai;
 
@@ -93,8 +98,12 @@
         /* test error */
         optlen = sizeof(ret);
         getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen);
-        if (ret != 0)
+        if (ret != 0) {
+            av_log(NULL, AV_LOG_ERROR,
+                   "TCP connection to %s:%d failed: %s\n",
+                   hostname, port, strerror(ret));
             goto fail;
+        }
     }
     s = av_malloc(sizeof(TCPContext));
     if (!s) {