def __init__(self, socket, config=None):

        if config is None:
            config = {}  # Do not use mutables as default arguments!
        threading.Thread.__init__(self)
        self.config = SimpleConfig(config) if type(config) == type({}) else config
        self.message_id = 0
        self.unanswered_requests = {}
        self.subscriptions = {}
        self.debug = False
        self.lock = threading.Lock()
        self.pending_transactions_for_notifications = []
        self.callbacks = {}
        self.running = True
        self.daemon = True

        if socket:
            self.pipe = util.SocketPipe(socket)
            self.network = None
        else:
            self.network = Network(config)
            self.pipe = util.QueuePipe(send_queue=self.network.requests_queue)
            self.network.start(self.pipe.get_queue)
            for key in ['status','banner','updated','servers','interfaces']:
                value = self.network.get_status_value(key)
                self.pipe.get_queue.put({'method':'network.status', 'params':[key, value]})

        # status variables
        self.status = 'connecting'
        self.servers = {}
        self.banner = ''
        self.blockchain_height = 0
        self.server_height = 0
        self.interfaces = []