|
Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
LInetHttp::Connect
#include "ltwrappr.h"
L_INT LInetHttp::Connect(pszServer, pszUserName = NULL, pszPassword = NULL, nPort = 80)
|
L_TCHAR *pszServer; |
/* name of server to connect to */ |
|
L_TCHAR *pszUserName; |
/* username for authentication */ |
|
L_TCHAR *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
Example
L_INT LInetHttp_ConnectExample(HWND hWndParent)
{
L_INT nRet;
LInetHttp InetHttp(TEXT("www.leadtools.com"));
// Checking if the connection failed
nRet = InetHttp.GetErrorFromList ();
if(nRet != SUCCESS)
{
InetHttp.DisplayError (hWndParent, TEXT("Can't connect to the HTTP web server"));
return nRet;
}
nRet = InetHttp.OpenRequest (HTTP_POST, TEXT("/default.htm"));
if(nRet != SUCCESS)
{
InetHttp.DisplayError(hWndParent, TEXT("Can't open a request"));
return nRet;
}
// Another code
InetHttp.CloseRequest ();
InetHttp.Disconnect ();
nRet = InetHttp.Connect(TEXT("www.leadtools.com"), TEXT("ABC"), TEXT("XYZ"));
if(nRet != SUCCESS)
{
InetHttp.DisplayError (hWndParent, TEXT("Can't connect to the HTTP web server, user-name or password may invalid!!"));
return nRet;
}
return SUCCESS;
}