Exemplo n.º 1
0
    def connect(self, connectionInfo, elementListener, onConnected):
        """
        Connect according to the info in connectionInfo, and use
        elementListener.

        :param UdpTransport.ConnectionInfo connectionInfo: A
          UdpTransport.ConnectionInfo.
        :param elementListener: The elementListener must remain valid during the
          life of this object.
        :type elementListener: An object with onReceivedElement
        :param onConnected: This calls onConnected() when the connection is
          established.
        :type onConnected: function object
        """
        self.close()
        # Save the _address to use in sendto.
        self._address = (connectionInfo.getHost(), connectionInfo.getPort())
        self._socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        if connectionInfo.getLocalPort() != None:
            self._socket.bind(("0.0.0.0", connectionInfo.getLocalPort()))

        self._socketPoller = SocketPoller(self._socket)
        self._elementReader = ElementReader(elementListener)

        if onConnected != None:
            onConnected()
Exemplo n.º 2
0
 def connect(self, connectionInfo, elementListener):
     """
     Connect according to the info in connectionInfo, and use 
     elementListener.
     
     :param UnixTransport.ConnectionInfo connectionInfo: A 
       UnixTransport.ConnectionInfo.
     :param elementListener: The elementListener must remain valid during the 
       life of this object.
     :type elementListener: An object with onReceivedData
     """
     self.close()
     self._socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
     self._socket.connect(connectionInfo.getFilePath())
       
     self._socketPoller = SocketPoller(self._socket)
     self._elementReader = ElementReader(elementListener)
Exemplo n.º 3
0
    def connect(self, connectionInfo, elementListener):
        """
        Connect according to the info in connectionInfo, and use 
        elementListener.
        
        :param UdpTransport.ConnectionInfo connectionInfo: A 
          UdpTransport.ConnectionInfo.
        :param elementListener: The elementListener must remain valid during the 
          life of this object.
        :type elementListener: An object with onReceivedData
        """
        self.close()
        # Save the _address to use in sendto.
        self._address = (connectionInfo.getHost(), connectionInfo.getPort())
        self._socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

        self._socketPoller = SocketPoller(self._socket)
        self._elementReader = ElementReader(elementListener)
Exemplo n.º 4
0
    def connect(self, connectionInfo, elementListener, onConnected):
        """
        Connect according to the info in connectionInfo, and use
        elementListener.

        :param UnixTransport.ConnectionInfo connectionInfo: A
          UnixTransport.ConnectionInfo.
        :param elementListener: The elementListener must remain valid during the
          life of this object.
        :type elementListener: An object with onReceivedElement
        :param onConnected: This calls onConnected() when the connection is
          established.
        :type onConnected: function object
        """
        self.close()
        self._socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
        self._socket.connect(connectionInfo.getFilePath())

        self._socketPoller = SocketPoller(self._socket)
        self._elementReader = ElementReader(elementListener)

        onConnected()