Communication with Sockets
This code sample is named SocketApp. It demonstrates the use of Windows Sockets to communicate with a mobile device. First, SocketApp uses Remote API (RAPI) interfaces to get the mobile device's IP address through ActiveSync. Second, SocketApp sends a "hello" string to the mobile device, and then listens for the mobile device to respond.
Feature Area
Relevant APIs
- EnumDevices function
- IRAPIDesktop:IUnknown function
- IRAPIDevice::GetConnectionInfo function
- IRAPIDevice:IUnknown function
Usage
To run the code sample
Navigate to the solution file (*.sln), and double-click it. By default, the solution file is copied to the following folder:
C:\Program Files\Windows CE Tools\wce500\Windows Mobile 5.0 Pocket PC SDK\Samples\CPP\Win32\Sockapp\``SocketApp.sln
Microsoft Visual Studio 2005 launches and loads the solution.
Open the Tools menu in Visual Studio, and navigate to Options, expand Projects and Solutions, and click VC++ Directories.
In Show directories for:, select Include files.
Add the path to the ActiveSync include directory. The default locations are:
C:\Program Files\Windows CE Tools\wce500\Windows Mobile 5.0 Pocket PC SDK\Activesync\Inc
for Pocket PC, andC:\Program Files\Windows CE Tools\wce500\Windows Mobile 5.0 Smartphone SDK\Activesync\Inc
for Smartphone.In Show directories for:, select Library files.
Add the path to the ActiveSync library directory. The default locations are:
C:\Program Files\Windows CE Tools\wce500\Windows Mobile 5.0 Pocket PC SDK\Activesync\Lib
for Pocket PC, andC:\Program Files\Windows CE Tools\wce500\Windows Mobile 5.0 Smartphone SDK\Activesync\Lib
for Smartphone.Build the solution (Ctrl+Shift+B).
Deploy the solution (F5).
To use the application
- Connect the mobile device.
- Launch "SocketSRV.exe" on the mobile device.
- Launch "SocClient.exe" from the desktop computer.
Remarks
The project file assumes that the Visual Studio default header and library search paths have been updated appropriately. For example, Windows Mobile PPC SDK will install ActiveSync library and header files to the following default locations:
C:\Program Files\Windows CE Tools\wce500\Windows Mobile 5.0 Pocket PC SDK\Activesync\Inc
C:\Program Files\Windows CE Tools\wce500\Windows Mobile 5.0 Pocket PC SDK\Activesync\Lib
Requirements
Pocket PC SDK: Windows Mobile 5.0 Pocket PC SDK.
Smartphone SDK: Windows Mobile 5.0 Smartphone SDK.
Development Environment: Visual Studio 2005.
ActiveSync: Version 4.0.
See Also
Send Feedback on this topic to the authors