network: Use av_strerror for getting error messages

Also use ff_neterrno() instead of errno directly (which doesn't work
on windows), for getting the error code.

Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
Martin Storsjö
2012-06-19 15:37:06 +03:00
parent 860b40f1f2
commit a840cdda6c
2 changed files with 23 additions and 14 deletions

View File

@@ -141,10 +141,12 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
optlen = sizeof(ret);
getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen);
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;
}
}