Figure 4    Winsock 2.0 versus WinInet

Winsock 2.0
Advantages Disadvantages
  1. Implements SSL/PCT securely outside of the application.
  2. Access to Internet and other application protocols such as telnet.
  3. High degree of flexibility.
  1. Need to embed knowledge of TCP/IP and Windows sockets.
  2. Need to embed knowledge of Internet protocols.
  3. More complex.
WinInet API 2.0
Advantages Disadvantages
  1. Using SSL is as simple as setting a flag.
  2. Eliminates the need to embed knowledge of TCP/IP and Windows sockets.
  3. Eliminates the need to embed knowledge of Internet protocols.
  4. 4
  5. Provides a constant interface to the evolving underlying protocols.
  6. Follows Win32 function standards.
  7. Fast implementation.
  1. Does not support application protocols such as telnet.
  2. Not as flexible.


Figure 5  WinInetSSL.cpp

HINTERNET hSession;
hSession = InternetOpen("MyApp", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
if (hSession)
{
    HINTERNET hService;
    hService = InternetConnect(hSession, "aarons.axtech.com", 
                               INTERNET_DEFAULT_HTTPS_PORT, NULL, NULL, 
                               INTERNET_SERVICE_HTTP, 0, 0);
    if (hService)
    {
        HINTERNET hHttpRequest;
    hHttpRequest = HttpOpenRequest(hService, "POST", "sample.cgi",
                                   NULL, NULL, NULL, INTERNET_FLAG_SECURE, 0);
        if (hHttpRequest)
        {
            char lpData[BUFFLEN] = {"SensitiveData=0123456789"};
    if (HttpSendRequest(hHttpRequest, NULL, 0, lpData, strlen(lpData)))
            {
                //read response
            }
        }            
    }
}
InternetCloseHandle(hSession);