Windows CE is often used
on embedded systems, on which there are limited resources. Most of Windows
CE devices don’t have disk drive, files are stored in memory, called object
store. Improved networking ability on devices will save the memory space,
achieve to access unlimited information through the global Internet, and
realize a disk-free computing. In this project, we have tried to develop
a networking application, and investigate the networking functions on Windows
CE.
A Practice of Windows CE Networking
To
design an Internet appliance on Windows CE, it follows above steps. At
the highest level, WinInet functions are ready to use to implement FTP
and HTTP-like applications, as we have practiced in the project. In reality,
WinInet functions wrap WinSock functions. WinSock is a set of functions
similar to UNIX BSD Socket. Socket functions help programmers saving the
details of TCP/IP protocol stacks. Programmers can either use WinSock or
WinInet functions for Internet applications, but they can’t directly use
TCP/IP functions, such as routing and IP forwarding, because those functions
work in OS kernel.
The MAC layer networking
schemes are included in network device driver. In Windows CE, it is called
NDIS(current version 4.0). Windows CE has a default network driver for
NE2000 compliance. But, NDIS belongs to external driver model That allows
third parties to develop their own drivers and add new networking features
on Windows CE.
(In above block
diagram, the boxes in green are accessable)
Our
project is trying to implement a HTTP client running on Windows CE. After
setting up a connection, the client sends HTTP requests to web server,
and retrieves the web page data, which later on is saved into a file for
parsing. HTTP protocol is specifically for web browsing applications. At
network and transportation layers, HTTP uses TCP/IP functions as it is
connection-oriented. In Microsoft Win32, there are already a set of functions
in WinInet just for HTTP and FTP Internet-based application protocols.
By using WinInet, I can avoid the complexity inside the protocols.
This
code (DoInet.cpp)
is modified from a sample code (httpdumpce.cpp) at Microsoft Windows CE
web site. It uses the OPENURL method by calling InternetOpenURL to send
web requests. To do an Internet web request, the procedures are following:
1.Declare
an Internet handler using InternetOpen();
2.Declare
an Internet handler and bind the specific URL to this handler using InternetOpenURL(),
this is because it may need multiple connections in one web page;
3.Get
the HTTP query information to check the status usingHttpQueryInfo();
4.Retrieve
HTTP header information also using HttpQueryInfo(), this tells the size
of web page;
5.Use
a while loop to receive the data of web page.
It
also need to convert the data into Unicode on Windows CE, and send the
data to callback function for Windows event dispatching.