def create_tcp_socket (self, host):
        """Create tcp socket, connect to it and return socket object."""
        port = int(self['TCPSocket'])
        sockinfo = get_sockinfo(host, port=port)
        sock = create_socket(socket.AF_INET, socket.SOCK_STREAM)
        try:
            sock.connect(sockinfo[0][4])
        except socket.error:
            sock.close()
            raise
        return sock
def create_tcp_socket ( self , host ) : port = int ( self [ 'TCPSocket' ] ) sockinfo = get_sockinfo ( host , port = port ) sock = create_socket ( socket . AF_INET , socket . SOCK_STREAM ) try : sock . connect ( sockinfo [ 0 ] [ 4 ] ) except socket . error : sock . close ( ) raise return sock
Create tcp socket, connect to it and return socket object.