albertz/shairport — Issue #136: C version tries to listen on IPv6 when it's not enabled
Author: JonahQuark
Created: 2012-02-04 14:34:26+00:00
State: open

The C version appears to attempt to listen on IPv6 when it is not available. This appears to be an extension of issue #75 which patched some of socket.c to fallback to IPv4.

When I run I get the following output:

/usr/local/src/shairport # ./shairport -vv
LogLevel: 7
AirName: ShairPort
HWID: dD&_$
HWID_Hex(12): 006444265F24
Avahi/DNS-SD started on PID: 7411
Starting connection server: specified server port: 5002
Listening on IPv6 Socket
Avahi/DNS-SD Name: 006444265F24@ShairPort
Failed to create ipv6 socket. Trying ipv4: Address family not supported by protocol
Error: Could not bind socket: Invalid argument
Error setting up server socket on port 5002, try specifying a different port

In socketlib.c issue #75 added detection which results in the output above about Failing to create IPv6 socket. However in setupListenServer() the code sets the socket to IPv6 using a #define. I've quickly fixed by commenting out the line :

tFamily = AF_INET6;

And it can then initialise correctly. I guess this need to do some runtime detection similar to patch in issue #75.