CodeGuru
Earthweb Search
Forums Wireless Jars Gamelan Developer.com
CodeGuru Navigation
Member Sign In
User ID:
Password:
Remember Me:
Forgot Password?
Not a member?
Click here for more information and to register.

jobs.internet.com

internet.commerce
Partners & Affiliates
Phone Cards
Promotional Gifts
Shop Online
Computer Hardware
KVM over IP
Laptop Batteries
Logo Design
Desktop Computers
Cell Phones
Computer Deals
Laptops
Logo Design Custom
KVM Switches
Corporate Awards


RSS Feeds

RSSAll

RSSVC++/C++

RSS.NET/C#

RSSVB

See more EarthWeb Network feeds

Home >> Visual C++ / C++ >> Windows Programming >> CE >> Embedded Visual C++

Project Management Guide: Developing a Web Site. Best Practices, Tips and Strategies. Download Exclusive eBook Now.

Wireless Communication in iPAQ Using Embedded Visual C++ 3.0
Rating: none

Badrinath Mohan (view profile)
July 17, 2002

Environment: Embedded VC++ 3.0

Introduction


(continued)



Download these IBM resources today!
e-Kit: IBM Rational Systems Development Solution
With systems teams under so much pressure to develop products faster, reduce production costs, and react to changing business needs quickly, communication and collaboration seem to get lost. Now, theres a way to improve product quality and communication.

Webcast: Asset Reuse Strategies for Success--Innovate Don't Duplicate!
Searching for, identifying, updating, using and deploying software assets can be a difficult challenge.

eKit: Rational Build Forge Express
Access valuable resources to help you increase staff productivity, compress development cycles and deliver better software, fast.

Download: IBM Data Studio v1.1
Effectively design, develop, deploy and manage your data, databases, and database applications throughout the data management life.

eKit: Rational Asset Manager
Learn how to do more with your reusable assets, learn how Rational Asset Manager tracks and audits your assets in order to utilize them for reuse.

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.

Downloads

Download source - 155 Kb

Tools:
Add www.codeguru.com to your favorites
Add www.codeguru.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed

Whitepaper: Enterprise Information Integration--Deployment Best Practices for Low-Cost Implementation
Flash Demo: Learn how IBM Information Server Blade is easy to manage, highly scalable and efficient.
Learn about expanding business opportunities for the reseller channel. Visit IT Channel Planet.
Best Practices for Developing a Web Site. Checklists, Tips & Strategies. Download Exclusive eBook Now.
Intel Go Parallel Portal: Translating Multicore Power into Application Performance


RATE THIS ARTICLE:   Excellent  Very Good  Average  Below Average  Poor  

(You must be signed in to rank an article. Not a member? Click here to register)

Latest Comments:
The definition of BSS and IBSS interchanged - Mathew Joy (02/24/2005)
the project would not compile - coolman (07/07/2004)
Very useful article - Legacy CodeGuru (01/17/2004)
cannot find zipdll.lib - Legacy CodeGuru (11/26/2003)
Excellent Article Just what I was looking for - Legacy CodeGuru (11/08/2003)

View All Comments
Add a Comment:
Title:
Comment:
Pre-Formatted: Check this if you want the text to display with the formatting as typed (good for source code)



(You must be signed in to comment on an article. Not a member? Click here to register)


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: Will Hyper-V Make VMware This Decade's Netscape?
Microsoft Article: 7.0, Microsoft's Lucky Version?
Microsoft Article: Hyper-V--The Killer Feature in Windows Server 2008
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Windows Server 2008
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES