Example #1
0
 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
Example #2
0
 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
Example #3
0
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)
Example #4
0
 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
Example #5
0
 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
Example #6
0
File: core.py Project: svinota/cx
 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)
Example #7
0
File: core.py Project: svinota/cx
 def close(self):
     """
     Close the socket
     """
     libc.close(self.fd)