Module tcpcom :: Class TCPClient
[hide private]
[frames] | no frames]

Class TCPClient

source code

Class that represents a TCP socket based client.

Instance Methods [hide private]
 
__init__(self, ipAddress, port, stateChanged, isVerbose=False)
Creates a TCP socket client prepared for a connection with a TCPServer at given address and port.
source code
 
sendMessage(self, msg, responseTime=0)
Sends the information msg to the server (as String, the character (ASCII 0) serves as end of string indicator, it is transparently added and removed).
source code
 
_waitForReply(self, responseTime) source code
 
connect(self, timeout=0)
Creates a connection to the server (blocking until timeout).
source code
 
disconnect(self)
Closes the connection with the server.
source code
 
isConnecting(self)
Returns True during a connection trial.
source code
 
isConnected(self)
Returns True of client is connnected to the server.
source code
Static Methods [hide private]
 
debug(msg) source code
 
getVersion()
Returns the library version.
source code
Class Variables [hide private]
  isVerbose = False
  CONNECTING = 'CONNECTING'
  SERVER_OCCUPIED = 'SERVER_OCCUPIED'
  CONNECTION_FAILED = 'CONNECTION_FAILED'
  CONNECTED = 'CONNECTED'
  DISCONNECTED = 'DISCONNECTED'
  MESSAGE = 'MESSAGE'
Method Details [hide private]

__init__(self, ipAddress, port, stateChanged, isVerbose=False)
(Constructor)

source code 

Creates a TCP socket client prepared for a connection with a TCPServer at given address and port.

Parameters:
  • host - the IP address of the host
  • port - the IP port where to listen (0..65535)
  • stateChanged - the callback function to register
  • isVerbose - if true, debug messages are written to System.out

sendMessage(self, msg, responseTime=0)

source code 

Sends the information msg to the server (as String, the character (ASCII 0) serves as end of string indicator, it is transparently added and removed). For responseTime > 0 the method blocks and waits for maximum responseTime seconds for a server reply.

Parameters:
  • msg - the message to send
  • responseTime - the maximum time to wait for a server reply (in s)
Returns:
the message or null, if a timeout occured

connect(self, timeout=0)

source code 

Creates a connection to the server (blocking until timeout).

Parameters:
  • timeout - the maximum time (in s) for the connection trial (0: for default timeout)
Returns:
True, if the connection is established; False, if the server is not available or occupied

isConnecting(self)

source code 

Returns True during a connection trial.

Returns:
True, while the client tries to connect

isConnected(self)

source code 

Returns True of client is connnected to the server.

Returns:
True, if the connection is established

getVersion()
Static Method

source code 

Returns the library version.

Returns:
the current version of the library