Module comm
source code
COMM module
Author: Michel F. Sanner Date: Oct 11 2000
This module implements the Comm class that provides bi-directional
communication over sockets. The Comm object provides server
functionality, accepting connections from multiple clients (each client
is handled by a separate thread). the comm object also provides client
side functionality, allowing a Comm object to connect to an existing
server.
A - Server side After a Comm object has been created, the startServer
method can be called to create a socket (self.serverSocket) and find a
free port to which this socket will be bound. The port is stored in
self.port
By calling the acceptClients(func, maxConnections) one can allow the
server to accept connection from clients. 'func' will be called for each
message sreceived from clients. FIXME: calling func should probably set a
lock. acceptClients works in its own thread. When a client connects, a
new thread is started to handle input from this client (listenToClient())
and the client is added to the Comm's clients dictionary.
The client dictionary uses the client's name as a key and stores the
socket and the address created by accept.
hangupClient(name, client) can be called to terminate a connection
with a specific client.
sendToClients(message) can be used to send a string to all connected
clients
B - Client side
A comm object can be used to connect to a running server using the
connectToServer(self, host, port, func). host cane be a host name or an
IP address (as string). If the connection is successful a new thread is
started to listen to the server and 'func' will be called with all
messages comming from that server.
disconnectFromServer(self, clientSocket) can be called to disconnect
fropm a server. 'clientSocket' can be a socket or a
|
foo1(client,
data)
|
|
foo(server,
data)
|
AI_ADDRCONFIG
None
-
- Value:
|
AI_NUMERICHOST
None
-
- Value:
|
CAPI
None
-
- Value:
<PyCObject object at 0xb79f1410>
|
|
EAI_ADDRFAMILY
None
-
- Value:
|
INADDR_ALLHOSTS_GROUP
None
-
- Value:
|
INADDR_BROADCAST
None
-
- Value:
|
INADDR_LOOPBACK
None
-
- Value:
|
INADDR_MAX_LOCAL_GROUP
None
-
- Value:
|
INADDR_UNSPEC_GROUP
None
-
- Value:
|
IPPORT_RESERVED
None
-
- Value:
|
IPPORT_USERRESERVED
None
-
- Value:
|
IPPROTO_DSTOPTS
None
-
- Value:
|
IPPROTO_FRAGMENT
None
-
- Value:
|
IPPROTO_HOPOPTS
None
-
- Value:
|
IPPROTO_ICMPV6
None
-
- Value:
|
IPPROTO_ROUTING
None
-
- Value:
|
IPV6_CHECKSUM
None
-
- Value:
|
IPV6_HOPLIMIT
None
-
- Value:
|
IPV6_JOIN_GROUP
None
-
- Value:
|
IPV6_LEAVE_GROUP
None
-
- Value:
|
IPV6_MULTICAST_HOPS
None
-
- Value:
|
IPV6_MULTICAST_IF
None
-
- Value:
|
IPV6_MULTICAST_LOOP
None
-
- Value:
|
IPV6_RTHDR_TYPE_0
None
-
- Value:
|
IPV6_UNICAST_HOPS
None
-
- Value:
|
IP_ADD_MEMBERSHIP
None
-
- Value:
|
IP_DEFAULT_MULTICAST_LOOP
None
-
- Value:
|
IP_DEFAULT_MULTICAST_TTL
None
-
- Value:
|
IP_DROP_MEMBERSHIP
None
-
- Value:
|
IP_MAX_MEMBERSHIPS
None
-
- Value:
|
IP_MULTICAST_IF
None
-
- Value:
|
IP_MULTICAST_LOOP
None
-
- Value:
|
IP_MULTICAST_TTL
None
-
- Value:
|
IP_RECVRETOPTS
None
-
- Value:
|
MSG_DONTROUTE
None
-
- Value:
|
NI_NUMERICHOST
None
-
- Value:
|
NI_NUMERICSERV
None
-
- Value:
|
PACKET_BROADCAST
None
-
- Value:
|
PACKET_FASTROUTE
None
-
- Value:
|
PACKET_LOOPBACK
None
-
- Value:
|
PACKET_MULTICAST
None
-
- Value:
|
PACKET_OTHERHOST
None
-
- Value:
|
PACKET_OUTGOING
None
-
- Value:
|
SOCK_SEQPACKET
None
-
- Value:
|
SO_ACCEPTCONN
None
-
- Value:
|
SSL_ERROR_EOF
None
-
- Value:
|
SSL_ERROR_INVALID_ERROR_CODE
None
-
- Value:
|
SSL_ERROR_SSL
None
-
- Value:
|
SSL_ERROR_SYSCALL
None
-
- Value:
|
SSL_ERROR_WANT_CONNECT
None
-
- Value:
|
SSL_ERROR_WANT_READ
None
-
- Value:
|
SSL_ERROR_WANT_WRITE
None
-
- Value:
|
SSL_ERROR_WANT_X509_LOOKUP
None
-
- Value:
|
SSL_ERROR_ZERO_RETURN
None
-
- Value:
|
TCP_DEFER_ACCEPT
None
-
- Value:
|
TCP_KEEPINTVL
None
-
- Value:
|
TCP_WINDOW_CLAMP
None
-
- Value:
|