A Brief Socket Tutorial

Team-Fly    

 
eMbedded Visual Basic: Windows CE and Pocket PC Mobile Applications
By Chris Tacke, Timothy Bassett
Table of Contents
Chapter 5.  Using the Windows CE WinSock for IR Communication


Sockets are simply a software "layer" between your application and your transfer protocol, which is usually TCP/IP. TCP/IP in turn talks to your networking hardware, which in turn sends your data somewhere or receives it from somewhere.

The sockets, and the WinSock control, make talking to TCP/IP simple, because you don't need to be concerned with packets, headers, or the like. You just need to know who you are and to whom you want to talk.

Socket communication requires two pieces: a sender, or client, and a receiver or server. The server listens through a socket on a port for any connection requests . The client uses a socket to request a connection to the server through its IP and port. When the server receives the request, it accepts the request and a connection is established.

From this point on, you can transfer data in both directions. Typically, a sender will tell the receiver how much data it's going to send. The receiver acknowledges this and sends back an "OK" and then data is sent. The Windows CE WinSock control even keeps these formalities behind the scenes.

Generally speaking, to use socket communication, you must have a TCP/IP stack, which on a PC generally means you must have a network card installed and the TCP/IP protocol loaded. On the Pocket PC this isn't necessarily the case, which means that even without a network card, you can write and use the sample application in this chapter. If you do have a network card installed, though, you can make a socket connection to any exposed IP address on your network or the Internet, provided that you have access rights.

If you have a device connected to your PC with ActiveSync through a serial or USB connection, there is actually a TCP/IP connection between the two, and any IP address requested by the device will get routed automatically to the PC. The Windows CE WinSock control also wraps the IrDA port on the device, so you can use the IR port as though it were a TCP/IP connection. Both features can be very valuable , as you'll see as we progress though the chapter.

Note

Because the Pocket PC emulator doesn't have an IR port, can't connect to ActiveSync, nor can it have a network card, you can't make a socket connection with it. This means that to take full advantage of this chapter, you will need a physical Pocket PC device.



Team-Fly    
Top
 


eMbedded Visual BasicR. WindowsR CE and Pocket PC Mobile Applications
eMbedded Visual BasicR. WindowsR CE and Pocket PC Mobile Applications
ISBN: N/A
EAN: N/A
Year: 2001
Pages: 108

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net