LInetHttp::Connect

#include "ltwrappr.h"

L_INT LInetHttp::Connect(pszServer, pszUserName = NULL, pszPassword = NULL, nPort = 80)

L_TCHAR L_FAR *pszServer;

/* name of server to connect to */

L_TCHAR L_FAR *pszUserName;

/* username for authentication */

L_TCHAR L_FAR *pszPassword;

/* password for authentication */

L_INT nPort;

/* port number to connect to */

Connects to an HTTP server.

Parameter

Description

pszServer

Character string that contains the name of the server to which to connect. The name can be a network name, an IP address, or a domain name (www.leadtools.com).

pszUserName

Character string that contains the name of the user logging on. Default value is NULL. This is a NULL-terminated string.

pszPassword

Character string that contains the password to use when logging on. If both pszPassword and pszUsername are NULL, the connection is made anonymously.

nPort

Number of the port to which to connect. The default port assignment for web servers is 80.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

Use this function to establish a connection with an HTTP Server. To connect anonymously pass NULL for pszUserName and pszPassword.

A connection to an HTTP server must be established before using any other HTTP functions. If a connection is disconnected, via either LInetHttp::Disconnect or LInetHttp::~LInetHttp, then a connection must be re-established before any other HTTP functions are called. LInetHttp::Connect and LInetHttp::LInetHttp can be used to establish a connection with an HTTP server.

Required DLLs and Libraries

LTWEB

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application

See Also

Functions:

LInetHttp::LInetHttp, LInetHttp::Disconnect, LInetHttp::OpenRequest, LInetHttp::CloseRequest, LInetHttp::SendBitmap, LInetHttp::SendData, LInetHttp::SendForm, LInetHttp::SendRequest, LInetHttp::GetResponse, LInetHttp::GetServerStatus, Class Members

Topics:

HTTP Functions: Connect / Disconnect Operations

 

How to Program with the LInetHttp Class

Example

L_VOID TestConnect(HWND hWndParent)
{
   LInetHttp InetHttp(TEXT("www.leadtools.com"));

   // Checking if the connection failed
   if(InetHttp.GetErrorFromList () != SUCCESS)
   {
      InetHttp.DisplayError (hWndParent, TEXT("Can't connect to the HTTP web server"));
      return;
   }

   if(InetHttp.OpenRequest (HTTP_POST, TEXT("/default.htm")) != SUCCESS)
   {
      InetHttp.DisplayError(hWndParent, TEXT("Can't open a request"));
      return;
   }

   // Another code

   InetHttp.CloseRequest ();
   InetHttp.Disconnect ();

   if(InetHttp.Connect(TEXT("www.leadtools.com"), TEXT("ABC"), TEXT("XYZ")) != SUCCESS)
   {
      InetHttp.DisplayError (hWndParent, TEXT("Can't connect to the HTTP web server, user-name or password may invalid!!"));
      return;
   }
}