4879c68 Improve address family handling in sockets

Authored and Committed by mkosek 8 years ago
    Improve address family handling in sockets
    Many functions use low-level socket interface for connection or
    various checks. However, most of the time we don't respect
    automatic address family detection but rather try to force our
    values. This may cause either redundat connection tries when an
    address family is disabled on system tries or even crashes
    when socket exceptions are not properly caught.
    Instead of forcing address families to socket, rather use
    getaddrinfo interface to automatically retrieve a list of all
    relevant address families and other connection settings when
    connecting to remote/local machine or binding to a local port.
    Now, we will also fill correctly all connection parameters like
    flowinfo and scopeid for IPv6 connections which will for example
    prevent issues with scoped IPv6 addresses.
    bind_port_responder function was changed to at first try to bind
    to IPv6 wildcard address before IPv4 as IPv6 socket is able to
    accept both IPv4 and IPv6 connections (unlike IPv4 socket).
    nsslib connection was refactored to use nss.io.AddrInfo class to
    get all the available connections. Socket is now not created by
    default in NSSConnection class initializer, but rather when the
    actual connection is being made, becase we do not an address family
    where connection is successful.
file modified
+75 -53
file modified
+34 -58