Wireless Communication in iPAQ Using Embedded Visual C++ 3.0
Environment: Embedded VC++ 3.0
Introduction
Many doubts exist regarding how to perform a wireless communication procedure between a wireless handheld client and a server (possibly a desktop) within a network. This article serves to remove any difficulties present in understanding the concept. Also, it aims to eliminate all sorts of confusion in establishing a communication procedure between two remote hosts.
A handheld can communicate with the server by means of a wireless card. In general, a wireless communication can be classified into the Independent Basic Service set (IBSS) or the Basic Service Set (BSS). The IBSS consists of those wireless networks wherein an Access point is provided which would help identify the remote clients. BSS is of the ad hoc nature, wherein no access points are provided. Let's not get into the technical intricacies of this wireless set of services. We shall now move towards establishing a simple wireless communication procedure between a handheld running Windows CE 3.0 and a desktop running any Windows OS.
A typical wireless scenario can be explained by the following figure. This is a typical scenario of the IBSS system.

Click here for a larger image.
For the handheld to become an active member in the wireless network, it should have an expansion pack with a wireless LAN card installed. Several companies such as 3COM, Lucent, and so forth, provide many LAN cards.
The first and foremost step would be install the corresponding driver in the handheld for your card to function perfectly. You need to read the documentation that comes with the card for the type of driver to install. That would not be difficult for anyone because it is well documented.
Once the driver is installed, your handheld is now ready to operate on the Internet. The iPAQ can be assigned IP addresses using this wireless LAN card. Once the IP address is assigned, the iPAQ becomes visible in the network. Communication can take place between the handheld and the desktop in the same network.
The 802.11 AP serves as the Network Access point, which is connected to the Ethernet. It consists of the LAN access Server Driver. When a wireless device needs to have the services of a LOCAL LAN, it connects to that using the Access points.
In the case of this approach, the iPAQ connecting as a client first communicates with the Access point to query the IP address of the server and then establishes the socket communication with the server. The socket communication that is established is the TCP or the reliable data communication. The client and the server then can exchange data with the help of the established datagram socket.
For perfect TCP communication to take place, you need to have two types of sockets. One is referred to as the listening socket and other is the communicating socket. Of course, this can also be done in several other methods but the one I chose is to have two different sockets so that multiple clients can be accommodated easily.
A typical socket can be created on the client side as:
m_pSocket = new CChatSocket (CCeSocket::FOR_DATA);
if (!m_pSocket->Create())
{
delete m_pSocket;
m_pSocket = NULL;
AfxMessageBox(CString("Socket Creation Failed"));
return FALSE;
}
if(!m_pSocket->Connect(lpszAddress, 707))
{
AfxMessageBox(CString(
"Socket failed to connect to the remote host"));
delete m_pSocket;
m_pSocket = NULL;
return FALSE;
}
On the server side, to accept this connection from the client, it has to be in listen mode. This can be implemented as follows:
#if defined(_WIN32_WCE) // Establish a socket to listen for incoming connections. m_pSocket = new CListeningSocket(this, CCeSocket::FOR_LISTENING ); #else // _WIN32_WCE m_pSocket = new CListeningSocket(this); #endif // _WIN32_WCE if (m_pSocket->Create( 707 )) { if (m_pSocket->Listen()) { return TRUE; } }
The connection from the client socket can be accepted as:
if (m_pSocket->Accept(*m_pClientSocket))
{
m_pClientSocket->Receive(szHost,25,0);
m_WndProgressCtrl.StepIt();
m_csHost=szHost;
}
After the mutual handshake between the client and the server, the communication can take place reliably and efficiently.

Click here for a larger image.
A sample project accompanies this article; it aims to provide a practical implementation of the wireless socket communication. Please download the entire attachment. You have to use Embedded Visual C++ to compile the project workspace ScreenPPC and Visual C++ to compile the ScreenDesktop project workspace.

Comments
The definition of BSS and IBSS interchanged
Posted by Mathew Joy on 02/24/2005 11:30pmthe project would not compile
Posted by coolman on 07/07/2004 06:15pmI am not able to compile the project can anybody help me out there.I am getting the error message that some header file is missing ie afxres.h is not found .
ReplyVery useful article
Posted by Legacy on 01/17/2004 12:00amOriginally posted by: Balakumar Krishnamurthi
Hi;
ReplyThe article was very useful for my purpose.
Regards
Bala
cannot find zipdll.lib
Posted by Legacy on 11/26/2003 12:00amOriginally posted by: SB
I tried compiling this application in evc++ 3.0 and it gives me a linker error saying "LINK : fatal error LNK1181: cannot open input file "zipdll.lib"
Any idea why?
thnkx
ReplyExcellent Article Just what I was looking for
Posted by Legacy on 11/08/2003 12:00amOriginally posted by: Abhishek
Great works badri
Thanks
Abhishek
ReplyCCeSocket...UDP
Posted by Legacy on 11/02/2003 12:00amOriginally posted by: D.K Chae
Hi.
I am looking for source of UDP sample in Win/CE. because, I Can send a data to server, but Can't receive from server datas. why don't event OnReceive() ??.
-
-
-
ReplyQuick and Dirty or Neat and Thorough?
Posted by .:{MM&I}:.CodeJockey on 05/20/2004 03:48amAssuming you don't have any problems at the trans source, the data is arriving at the CE/PPC object. Dinking around this issue for two days, I've reached a conclusion: CCeSocket does not comfortably work with UDP (for CE3/PPC2002 and earlier, at least.) In the MFC source, CCeSocket looks for connection (suggesting TCP only, which won't serve you since UDP is connectionless...) however, looking at the source points out what is missing. The significant feature of CCeSocket is a pair of threads, one for TCP client data and one for TCP listening. The job of the data thread is to poll using ioctrlsocket then launch the "WM_NOTIFY_SOCKET" to a placeholder window of the socket. It's not necessary to duplicate this entirely. Instead of deriving from CCeSocket, derive from CAsyncSocket and: Quick and Dirty: add a timer to your frame window to poll ioctrlsocket then call OnReceive or Neat and Thorough: manually build an override of Create that launches a thread which polls ioctrlsocket, in turn, calling OnReceive.
ReplyKnown bug regarding OnReceive in WinCe & SOLUTION
Posted by Ishan125 on 04/01/2004 11:32pmI've just been having this same problem and stumbled across this MSDN bug report from Microsoft addressing this specifically (with SOLUTION!) http://www.kbalertz.com/Feedback_253945.aspx
ReplyCCeSocket...UDP...problem to receive data
Posted by jonzuzu on 03/24/2004 03:37ami have exactly the same problem in my application it runs when the server is on my desktop i receive the data but when i want to receive data on the pocket pc the OnReceive() function is never called... If someone know this problem, please help me
ReplyGreat article - how about UDP?
Posted by Legacy on 09/19/2003 12:00amOriginally posted by: Vikki Pitts
Enjoyed the article - thought it was very clear.
How about some samples for connectionless UDP sockets?
Replycannot open input file "zipdll.lib"
Posted by Legacy on 08/15/2003 12:00amOriginally posted by: Jim
I use Embedded Visual C++ 3.0 to compile the project
workspace ScreenPPC. I am not lucky. I cannot pass
the compiler. I got the following error message:
LINK : fatal error LNK1181: cannot open input
file "zipdll.lib"
Please advise! Thanks!
Jim
ReplyProblems with TCP/IP on Pocket PC 2002
Posted by Legacy on 07/11/2003 12:00amOriginally posted by: Ben Clewett
I can connect, send, receive, disconnect ok. But having two real problems. Firstly, connection, if connecing port non-existant, does not time out. Lockes 'connect' call for ever more. Secondly, the Microsoft advised way of checking if TCP/IP connection still working using 'select' does not work.
Does any other member report these problems, and possibly know of a fix?
Thanks, Ben Clewett.
ReplyHelp on wireless
Posted by Legacy on 03/09/2003 12:00amOriginally posted by: Tristan
Hi! Anyone knows how to send files across SSID oR BSSID network?
ReplyLoading, Please Wait ...