This section provides a step by step overview over what happens in the simple client and server programs we just implemented.
Server:
-
Server program started.
-
The server gets instantiated, the server socket initialized.
-
The server program enters the mainloop, in which, through calls to ZCom_processInput/Output, Zoidcom is waiting for data to arrive.
Client:
-
Client program started.
-
Client gets instantiated, the client socket initialized.
-
The client prepares the target address and issues a ZCom_Connect() call, which is not yet sent! The call attaches the password 'let_me_in' to the connection request.
-
Client enters the mainloop, the first call to ZCom_processOutput() will send the connection request packet.
Server:
-
The packet will arrive at the server sometime later and Zoidcom queues it internally.
-
The next time the server program calls ZCom_processInput() the queued packet from the client will get processed.
-
ZCom_processInput() will detect that the queued packet was a connection request. ZCom_cbConnectionRequest() is called.
-
ZCom_cbConnectionRequest() checks if the password is 'let_me_in' and returns 'true', telling ZCom_processInput() that the server wants to accept the connection
-
Zoidcom will generate a reply packet, but it won't get sent yet!
-
Next call to ZCom_processOutput() on the server will send the connection reply packet.
Client:
-
Client received the packet, queues it internally until ZCom_processInput() is called.
-
ZCom_processInput() detects that this is a reply to the earlier connection request. ZCom_cbConnectResult() is called.
-
Inside ZCom_cbConnectResult(), the client generates a message for the server, stating that it wants to receive the string "Hello from Server" nine times. The message is queued.
-
Next call to ZCom_processOutput() on the client will send the message.
Server:
-
Server receives it, ZCom_processInput() will call ZCom_cbDataReceived().
-
ZCom_cbDataReceived() on server reads the value from the message, and generates 9 reply messages, each containing the string "Hello from Server"
-
Next call to ZCom_processOutput() on server will detect the waiting messages and wrap them up in a packet. If there is more data waiting than can fit into one packet, the remainding messages will get sent in the next call to ZCom_processOutput().
Client:
-
Client receives and queues the packet.
-
ZCom_processInput() on client will detect the packet and call ZCom_cbDataReceived() 9 times, one time for each message in the packet.
-
ZCom_cbDataReceived() reads the string from each message and prints it to the console.
This file is part of the documentation for Zoidcom. Documentation copyright © 2004-2007 by Jörg Rüppel. Generated on Wed Jan 3 20:38:20 2007 for Zoidcom by
1.4.6-NO