Exemplo n.º 1
0
   def handleNewConnection(self):
      """\
      Handle notifications from the selector service of new connection requests.

      Accepts and sets up new connections, wiring them up and passing them on via
      the "protocolHandlerSignal" outbox.
      """
      if self.dataReady("newconnection"):
         data = self.recv("newconnection")
         # If we recieve information on data ready, for a server it means we have a new connection
         # to handle
         try:
            newsock, CSA = self.createConnectedSocket(self.listener)
         except socket.error, e:
            (errorno,errmsg) = e
            if errorno != errno.EAGAIN:
               if errorno != errno.EWOULDBLOCK:
                  raise e
         else:
             pass

             self.send(_ki.newCSA(self, CSA), "protocolHandlerSignal")
             self.send(newReader(CSA, ((CSA, "ReadReady"), newsock)), "_selectorSignal")            
             self.send(newWriter(CSA, ((CSA, "SendReady"), newsock)), "_selectorSignal")            
             self.addChildren(CSA)
             self.link((CSA, "CreatorFeedback"),(self,"_feedbackFromCSA"))
             return CSA
Exemplo n.º 2
0
    def handleNewConnection(self):
        """\
      Handle notifications from the selector service of new connection requests.

      Accepts and sets up new connections, wiring them up and passing them on via
      the "protocolHandlerSignal" outbox.
      """
        if self.dataReady("newconnection"):
            data = self.recv("newconnection")
            # If we recieve information on data ready, for a server it means we have a new connection
            # to handle
            try:
                newsock, CSA = self.createConnectedSocket(self.listener)
            except socket.error, e:
                (errorno, errmsg) = e
                if errorno != errno.EAGAIN:
                    if errorno != errno.EWOULDBLOCK:
                        raise e
            else:
                pass

                self.send(_ki.newCSA(self, CSA), "protocolHandlerSignal")
                self.send(newReader(CSA, ((CSA, "ReadReady"), newsock)),
                          "_selectorSignal")
                self.send(newWriter(CSA, ((CSA, "SendReady"), newsock)),
                          "_selectorSignal")
                self.addChildren(CSA)
                self.link((CSA, "CreatorFeedback"), (self, "_feedbackFromCSA"))
                return CSA
Exemplo n.º 3
0
   def closeSocket(self, shutdownMessage):
      """\
      Respond to a socketShutdown message by closing the socket.

      Sends a removeReader and removeWriter message to the selectorComponent.
      Sends a shutdownCSA(self, theCSA) message to "protocolHandlerSignal" outbox.
      """
      theComponent,sock = shutdownMessage.caller, shutdownMessage.message
      sock.close()
      
      # tell the selector about it shutting down
      
      self.send(removeReader(theComponent, theComponent.socket), "_selectorSignal")            
      self.send(removeWriter(theComponent, theComponent.socket), "_selectorSignal")

      # tell protocol handlers
      self.send(_ki.shutdownCSA(self, theComponent), "protocolHandlerSignal")# "signal")
      # Delete the child component
      self.removeChild(theComponent)
Exemplo n.º 4
0
    def closeSocket(self, shutdownMessage):
        """\
      Respond to a socketShutdown message by closing the socket.

      Sends a removeReader and removeWriter message to the selectorComponent.
      Sends a shutdownCSA(self, theCSA) message to "protocolHandlerSignal" outbox.
      """
        theComponent, sock = shutdownMessage.caller, shutdownMessage.message
        sock.close()

        # tell the selector about it shutting down

        self.send(removeReader(theComponent, theComponent.socket),
                  "_selectorSignal")
        self.send(removeWriter(theComponent, theComponent.socket),
                  "_selectorSignal")

        # tell protocol handlers
        self.send(_ki.shutdownCSA(self, theComponent),
                  "protocolHandlerSignal")  # "signal")
        # Delete the child component
        self.removeChild(theComponent)