Example: interface on server – Rockwell Automation 2727-G7P20D3Q7 MobileView G750 Guard Machine Terminal User Manual

Page 100

Advertising
background image

Publication 2727-UM002D-EN-P

7-6 Windows CE Applications

Example: Interface on Server

On the server side, the VC protocol is represented by two classes:
CKVCServerand 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 CKVCConnection* OnClientConnect(const char
*pIpAdr)= 0;
virtual int OnClientDisconnect(CKVCConnection
*pConnection,
TDisconInfo info);

};

CKVCConnection* OnClientConnect(SOCKET socket, sockaddr_in
&sockAdr);

This method is always called when a terminal establishes a connection
to the control. The parameters socket and sockAdr specify the
connection parameters of the terminal. This function must return a
pointer to an object of the CKVCConnection class. A return value of
0 indicates that the control rejects the logon of the terminal.

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.

Advertising