(self, exceptions, addr_info, local_addr_infos=None)
Create, bind and connect one socket.
Create, bind and connect one socket.
Create bind and connect one socket .
async def _connect_sock(self, exceptions, addr_info, local_addr_infos=None):
        """Create, bind and connect one socket."""
        my_exceptions = []
        exceptions.append(my_exceptions)
        family, type_, proto, _, address = addr_info
        sock = None
        try:
            sock = socket.socket(family=family, type=type_, proto=proto)
            sock.setblocking(False)
            if local_addr_infos is not None:
                for _, _, _, _, laddr in local_addr_infos:
                    try:
                        sock.bind(laddr)
                        break
                    except OSError as exc:
                        msg = (
                            f'error while attempting to bind on '
                            f'address {laddr!r}: '
                            f'{exc.strerror.lower()}'
                        )
                        exc = OSError(exc.errno, msg)
                        my_exceptions.append(exc)
                else:  # all bind attempts failed
                    raise my_exceptions.pop()
            await self.sock_connect(sock, address)
            return sock
        except OSError as exc:
            my_exceptions.append(exc)
            if sock is not None:
                sock.close()
            raise
        except:
            if sock is not None:
                sock.close()
            raise
async def _connect_sock ( self , exceptions , addr_info , local_addr_infos = None ) : my_exceptions = [ ] exceptions . append ( my_exceptions ) family , type_ , proto , _ , address = addr_info sock = None try : sock = socket . socket ( family = family , type = type_ , proto = proto ) sock . setblocking ( False ) if local_addr_infos is not None : for _ , _ , _ , _ , laddr in local_addr_infos : try : sock . bind ( laddr ) break except OSError as exc : msg = ( f'error while attempting to bind on ' f'address {laddr!r}: ' f'{exc.strerror.lower()}' ) exc = OSError ( exc . errno , msg ) my_exceptions . append ( exc ) else : # all bind attempts failed raise my_exceptions . pop ( ) await self . sock_connect ( sock , address ) return sock except OSError as exc : my_exceptions . append ( exc ) if sock is not None : sock . close ( ) raise except : if sock is not None : sock . close ( ) raise