def __init__(self, host=None, port=None, **kwargs):
        """Initialize a connection to the network socket.

        Kwargs:
            host - optionally override the default network host (default is local machine)
            port - optionally override the default network port (default is 50001)
            log_mode - optionally record or print logs from the network source

        Raises:
            DataSourceError if the socket connection cannot be opened.
        """
        super(NetworkDataSource, self).__init__(**kwargs)
        self.host = host or socket.gethostbyname(socket.gethostname())
        self.port = port or self.DEFAULT_PORT
        self.port = int(self.port)

        try:
            self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            self.socket.connect((self.host, self.port))
        except (__HOLE__, socket.error) as e:
            raise DataSourceError("Unable to open socket connection at  "
                    "%s:%s: %s" % (self.host,self.port, e))
        else:
            LOG.debug("Opened socket connection at %s:%s", self.host, self.port)
dataset/ETHPy150Open openxc/openxc-python/openxc/sources/network.py/NetworkDataSource.__init__