def accept(self):
        with self.lock:
            if self.state.SHUTDOWN:
                raise Error(errno.EBADF)
            if not self.state.LISTEN:
                self.err("accept() but socket state is {0}".format(self.state))
                raise Error(errno.EINVAL)
            self.recv_buf += 1
            try: pdu = super(DataLinkConnection, self).recv()
            except IndexError: raise Error(errno.EPIPE)
            self.recv_buf -= 1
            if isinstance(pdu, Connect):
                dlc = DataLinkConnection(self.recv_miu, self.recv_win)
                dlc.addr = self.addr
                dlc.peer = pdu.ssap
                dlc.send_miu = pdu.miu
                dlc.send_win = pdu.rw
                pdu = ConnectionComplete(dlc.peer, dlc.addr)
                pdu.miu, pdu.rw = dlc.recv_miu, dlc.recv_win
                log.info("accepting CONNECT from SAP %d" % dlc.peer)
                dlc.state.ESTABLISHED = True
                self.send_queue.append(pdu)
                return dlc
            raise RuntimeError("only CONNECT expected, not "+ pdu.name)
dataset/ETHPy150Open javgh/greenaddress-pos-tools/nfc/llcp/tco.py/DataLinkConnection.accept/original