1 //////////////////////////////////////////////
\r
8 // User defined message
\r
9 #define USER_ACCEPT WM_APP+1
\r
10 #define USER_CONNECT WM_APP+2
\r
11 #define USER_DISCONNECT WM_APP+3
\r
12 #define USER_RECEIVE WM_APP+4
\r
16 // For a TCP server, inherit a class from CSocket and override OnAccept, OnDisconnect
\r
17 // and OnRecieve. Create one instance of this class and use it as a listening socket.
\r
18 // The purpose of the listening socket is to detect connections from clients and accept them.
\r
19 // For the listening socket, we do the following:
\r
20 // 1) Create the socket.
\r
21 // 2) Bind an IP address to the socket.
\r
22 // 3) Listen on the socket for incoming connection requests.
\r
23 // 4) Use StartNotifyRevents to receive notification of network events.
\r
24 // 5) Override OnAccept and Accept requests on a newly created data CSocket object.
\r
26 // The purpose of the data socket is to send data to, and recieve data from the client.
\r
27 // There will be one data socket for each client accepted by the server.
\r
28 // It is already set up ready for use by Accept. To use it we do the following:
\r
29 // * To recieve data from the client, override OnReceive and use Receive.
\r
30 // * To send data to use Send.
\r
31 // * OnDisconnect can be used to detect when the client is disconnected.
\r
33 // For a TCP client, inherit from CSocket and override OnReceive and OnDisconnect.
\r
34 // Create an instance of this inherited class, and perform the following steps:
\r
35 // 1) Create the socket.
\r
36 // 2) Connect to the server.
\r
37 // 3) Use StartNotifyRevents to receive notification of network events.
\r
38 // We are now ready to send and recieve data from the server.
\r
39 // * Use Send to send data to the server.
\r
40 // * Override OnReceive and use Recieve to receive data from the server
\r
41 // * OnDisconnect can be used to detect when the client is disconnected from the server.
\r
45 /////////////////////////////////////////
\r
46 // Declaration of the CServerSocket class
\r
48 class CServerSocket : public CSocket
\r
52 virtual ~CServerSocket() { }
\r
53 virtual void OnAccept();
\r
54 virtual void OnDisconnect();
\r
55 virtual void OnReceive();
\r