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()
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)
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)
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()