summaryrefslogtreecommitdiff
path: root/libavformat/tcp.c
diff options
context:
space:
mode:
authorJordi Ortiz <nenjordi@gmail.com>2012-06-26 19:22:21 +0200
committerMartin Storsjö <martin@martin.st>2012-06-27 14:04:02 +0300
commitef882e464ab270276f56c1088da646a8080b8460 (patch)
tree32e409b0b1bdb6bb33f361c479a0a6ce1150e45e /libavformat/tcp.c
parent58f3e09ee4cd7fe4b757797f0828fc3549c58535 (diff)
tcp: Pass NULL as hostname to getaddrinfo if the string is empty
This gives you the proper v4 or v6 version of the "any address", allowing receiving connections on any address on the machine. Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/tcp.c')
-rw-r--r--libavformat/tcp.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index 5313195e5c..6a65860b5f 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -65,7 +65,10 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
snprintf(portstr, sizeof(portstr), "%d", port);
if (listen_socket)
hints.ai_flags |= AI_PASSIVE;
- ret = getaddrinfo(hostname, portstr, &hints, &ai);
+ if (!hostname[0])
+ ret = getaddrinfo(NULL, portstr, &hints, &ai);
+ else
+ ret = getaddrinfo(hostname, portstr, &hints, &ai);
if (ret) {
av_log(h, AV_LOG_ERROR,
"Failed to resolve hostname %s: %s\n",