Software KeTop T100
84 User's Manual, version: 3.1 / material no.: 57448
© KEBA 2006
Example: Interface on Server
On the server side, the KVC protocol is represented by two classes:
CKVCServer and CKVCConnection. An object of the CKVCServer class
represents the actual server (the "listener") and an object of the
CKVCConnection class represents a connection to a client.
"Server class"
class CKVCServer {
public:
virtual int Init();
virtual int Exit();
virtual CKVCConnection* OnClientConnect(SOCKET socket,
sockaddr_in
&sockAdr);
virtual int OnClientDisconnect(CKVCConnection *pConnection,
TDisconInfo info);
POSITION ConnectionListHeadPos();
CKVCConnection* ConnectionListGetNext(POSITION pos);
int ConnectionListGetCount();
};
int Init();
Initalizes the server and opens the port 0xCEBA for
incoming connections.
int Exit();
Finishes all connections and closes the port 0xCEBA.
CKVCConnection* OnClientConnect(SOCKET socket, sockaddr_in
&sockAdr);
This method is always called when a teach pendant establishes a connec-
tion to the control. The parameters
socket and sockAdr specify the con-
nection parameters of the teach pendant. This function must return a
pointer to an object of the class
CKVCConnection. A return value of 0 indi-
cates that the control rejects the logon of the teach pendant.
int OnClientDisconnect(CKVCConnection *pConnection,
TDisconInfo info);
This method will be called if the server cannot reach the client any more.
The cause of the logoff is specified in info.
POSITION ConnectionListHeadPos();
This method returns the position of the first entry in the OpenConnection
list.
CKVCConnection* ConnectionListGetNext(POSITION pos);
This method returns a pointer to the ConnectionObject that is stored on the
postiion pos in the OpenConnection list.
int ConnectionListGetCount();
This method returns the number of connections that are stored in the
OpenConnection list.