Commit 63638a3c authored by Ronald S. Bultje's avatar Ronald S. Bultje

Print error messages in case of connection failure or name resolution failure

in tcp.c.

Originally committed as revision 24796 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent afbc4d2d
...@@ -54,8 +54,13 @@ static int tcp_open(URLContext *h, const char *uri, int flags) ...@@ -54,8 +54,13 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
hints.ai_family = AF_UNSPEC; hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;
snprintf(portstr, sizeof(portstr), "%d", port); 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); return AVERROR(EIO);
}
cur_ai = ai; cur_ai = ai;
...@@ -93,9 +98,13 @@ static int tcp_open(URLContext *h, const char *uri, int flags) ...@@ -93,9 +98,13 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
/* test error */ /* test error */
optlen = sizeof(ret); optlen = sizeof(ret);
getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen); 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; goto fail;
} }
}
s = av_malloc(sizeof(TCPContext)); s = av_malloc(sizeof(TCPContext));
if (!s) { if (!s) {
freeaddrinfo(ai); freeaddrinfo(ai);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment