def run(self): """ Receive and transmit messages """ self.debug("Start a new session") try: while not self.__sock.closed: try: (l, msg) = self.recv() self.debug("%i bytes received" % l) except IOError: break if msg.type == Tflush._type: self.markflushed(msg.oldtag) self.debug("Flush the %i tag" % msg.oldtag) self.reply(basereply(msg), False) else: self.__sock.enqueue(self, msg) libc.close(self.__clsock) self.closed = True self.debug("The session is closed") except: libc.close(self.__clsock) self.closed = True self.debug("The session is closed on an error") raise
def run (self): """ Receive and transmit messages """ self.debug ("Start a new session") try: while not self.__sock.closed: try: (l, msg) = self.recv() self.debug ("%i bytes received" % l) except IOError: break if msg.type == Tflush._type: self.markflushed (msg.oldtag) self.debug ("Flush the %i tag" % msg.oldtag) self.reply (basereply(msg), False) else: self.__sock.enqueue (self, msg) libc.close(self.__clsock) self.closed = True self.debug ("The session is closed") except: libc.close(self.__clsock) self.closed = True self.debug ("The session is closed on an error") raise
def hdump(name, msg, size=0): """ Dump a packet into a file """ if not size: size = sizeof(msg) fd = libc.open(name, 577, 384) libc.write(fd, byref(msg), size) libc.close(fd)
def close(self): """ Close the socket """ for i in range(QTHREADS): self.enqueue(None, None) self.debug("Waiting for queue workers to finish...") self.__msgq.join() libc.close(self.fd) self.closed = True
def close(self): """ Close the socket """ for i in range(QTHREADS): self.enqueue (None, None) self.debug ("Waiting for queue workers to finish...") self.__msgq.join() libc.close(self.fd) self.closed = True
def serve(self): """ 9p server """ libc.listen(self.fd,10) while True: sa = sockaddr_in() s = libc.accept(self.fd, byref(sa), byref(c_uint32(sizeof(sa)))) (l,msg) = self.recv(s) print("got message of",l,"bytes") print(msg) libc.close(s)
def close(self): """ Close the socket """ libc.close(self.fd)