Re: libsoup and IPv6



On 01/03/2011 05:42 PM, W. Michael Petullo wrote:
> addr = soup_address_new_any (addr_family, port);
> share->priv->server = soup_server_new (SOUP_SERVER_INTERFACE, addr, NULL);
> 
> What I am finding is that if addr_family is SOUP_ADDRESS_FAMILY_IPV4,
> then the server is available using IPv4. However, if I use
> SOUP_ADDRESS_FAMILY_IPV6, then the server is available using *both*
> IPv4 and v6. I guess I would expect the latter to be IPv6 only.
> 
> I think the behavior that I am seeing will make things more convenient
> for me. I just want to make sure I am not doing anything wrong. Where is
> it documented that SOUP_ADDRESS_FAMILY_IPV6 means that the service will
> be available on both IPv4 and IPv6? Or am I interpreting this incorrectly?

This is an optional feature of the IPv6 sockets API, which Linux
implements and most other OSes don't. (Or rather, it's run-time
configurable via a sysctl, and it defaults to "on" on Linux and "off"
everywhere else.) If you get an IPv4 connection on the socket, the
address will be returned to you as a v6-wrapped IPv4 address (ie,
IN6_IS_ADDR_V4MAPPED() on the in6_addr will return TRUE).

For maximum compatibility, you should create the IPv6 socket first, and
then try to create an IPv4 socket too on the same port, but if that
fails, assume it's because the IPv6 socket is listening on both ports.

There may be some more explicit API around this in the future (eg, gio's
g_socket_speaks_ipv4()).

-- Dan


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]