diff options
Diffstat (limited to 'libavformat/tcp.c')
-rw-r--r-- | libavformat/tcp.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/libavformat/tcp.c b/libavformat/tcp.c index 1cc7e0a6be..c42c1edbf3 100644 --- a/libavformat/tcp.c +++ b/libavformat/tcp.c @@ -28,7 +28,6 @@ #if HAVE_POLL_H #include <poll.h> #endif -#include <sys/time.h> typedef struct TCPContext { int fd; @@ -139,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; } } |