def __init__(self, address, blocking=1, timeout=15): """Initialize an object with an address and an optional blocking flag.""" self.header = '' self.timeout = timeout ClientServerSocket.__init__(self, address, blocking=blocking)
def open(self, timeout=None, authenticate=1): """Overloaded to provide the global timeout.""" if timeout is None: timeout = self.timeout ClientServerSocket.open(self, timeout=timeout, authenticate=authenticate)
def open(self, timeout=None, authenticate=1, **kwargs): """Clears the authentication information before opening the connection.""" self.authMsgSent = 0 self.authenticated = 0 if timeout is None: timeout = self.timeout ClientServerSocket.open(self, timeout=timeout, authenticate=authenticate, **kwargs)
def __init__(self, address, timeout=TimeoutInterval, keepalive=0, **kwargs): """Initialize the object by setting an authenticated flag to keep track of whether or not the connection has been authenticated yet or not.""" self.authenticated = 0L self.timeout = timeout self.keepalive = keepalive self.authMsgSent = 0 # the actual address will be decided when open is called ClientServerSocket.__init__(self, address, **kwargs)
def close(self, msg='quit'): """Closes the connection with the server by sending 'quit' to cleanly close the connection.""" if msg: try: self.sendCmd('quit', readresp=0) # it's possible that we are already disconnected except Sockets.SocketError: pass ClientServerSocket.close(self)
def close(self, msg='quit'): """Close the connection with server.""" # if this is a keepalive connection then make sure we tell the # server that we are done. if self.keepalive and msg: try: self.send({'close': msg}, timeout=self.timeout) # it's possible that we are already disconnected except Sockets.SocketError: pass ClientServerSocket.close(self)
def send(self, msg, timeout=0): """Appends the newline character to the string before sending.""" ClientServerSocket.send(self, msg + '\n', timeout=timeout)