CCeSocket

This class is derived from the CSocket class. If you want to use asynchronous communication in Windows CE, you must use the CCeSocket class. Windows CE does not inherently support asynchronous socket communication, but the CCeSocket class provides asynchronous notification for the following three types of socket events:

At a Glance

Header file: Wcesock.h
Platforms: H/PC 2.0, Palm-size PC, H/PC Pro
Windows CE versions: 2.0 and later

Remarks

Use the CCeSocket class, or a class derived from CCeSocket, for Windows CE applications, rather than using CSocket or CAsyncSocket.

The CSocket and CAsyncSocket classes rely on the standard Windows message-based notification of network events, but Windows CE does not support asynchronous event notification. Without access to asynchronous event notification, an application would have to poll for network events that it wished to handle. This would be very inefficient. The CCeSocket class achieves the effect of asynchronous event notification by creating two threads that monitor socket events. When a thread detects one of the three events for which the CCeSocket class provides notifications, it sends a message to the appropriate handler. All instances of CCeSocket share the same two monitor threads.

MFC for Windows CE supports a global function and a window message that you can use in conjunction with the CCeSocket class. Use the WM_SOCKET_NOTIFY message in a Windows CE application to notify a socket of an asynchronous event, for example, when the socket to which it is connected is closing. The WM_SOCKET_NOTIFY message is processed by a socket window that is maintained as part of the module’s thread state. Use the AfxGetCeSocketWindow function to obtain the handle to this window.

The CHATTER/CHATSRVR sample programs demonstrate how to use the CCeSocket class. You can find them in the Wce\Samples\Mfc directory.

See Also

CArchive, CAsyncSocket, CSocketFile, Unique MFC Classes for Windows CE