summaryrefslogtreecommitdiff
path: root/libavformat/tcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavformat/tcp.c')
-rw-r--r--libavformat/tcp.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index 2fb6a8a584..42dcee0c16 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -63,7 +63,12 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
snprintf(portstr, sizeof(portstr), "%d", port);
- ret = getaddrinfo(hostname, portstr, &hints, &ai);
+ if (listen_socket)
+ hints.ai_flags |= AI_PASSIVE;
+ 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",