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>
This commit is contained in:
		
				
					committed by
					
						
						Martin Storsjö
					
				
			
			
				
	
			
			
			
						parent
						
							58f3e09ee4
						
					
				
				
					commit
					ef882e464a
				
			@@ -65,6 +65,9 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
 | 
				
			|||||||
    snprintf(portstr, sizeof(portstr), "%d", port);
 | 
					    snprintf(portstr, sizeof(portstr), "%d", port);
 | 
				
			||||||
    if (listen_socket)
 | 
					    if (listen_socket)
 | 
				
			||||||
        hints.ai_flags |= AI_PASSIVE;
 | 
					        hints.ai_flags |= AI_PASSIVE;
 | 
				
			||||||
 | 
					    if (!hostname[0])
 | 
				
			||||||
 | 
					        ret = getaddrinfo(NULL, portstr, &hints, &ai);
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
        ret = getaddrinfo(hostname, portstr, &hints, &ai);
 | 
					        ret = getaddrinfo(hostname, portstr, &hints, &ai);
 | 
				
			||||||
    if (ret) {
 | 
					    if (ret) {
 | 
				
			||||||
        av_log(h, AV_LOG_ERROR,
 | 
					        av_log(h, AV_LOG_ERROR,
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user