L_InetHttpConnect
#include "ltweb.h"
L_INT EXT_FUNCTION L_InetHttpConnect(pszServer, iPort, pszUserName, pszPassword, pHttp)
/* name of server to connect to*/ | |
L_INT iPort; |
/* port number to connect to*/ |
/* username for authentication*/ | |
/* password for authentication*/ | |
pHINET pHttp |
/* address of the variable to be updated*/ |
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). |
iPort |
Number of the port to which to connect. The default port assignment for Internet servers is 80. |
pszUserName |
Character string containing the username to be used for authentication. |
pszPassword |
Character string containing the password to be used for authentication. |
pHttp |
Address of the variable to be updated with the Http connection. |
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.
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: |
|
Topics: |
|
|
Example
void TestSendForm()
{
HINET hInet;
L_INT nRet;
NAMEVALUE nv[2];
nRet = L_InetHttpConnect(TEXT("www.leadtools.com"),80,TEXT(""),TEXT(""),&hInet);
if(nRet==SUCCESS)
{
nRet = L_InetHttpOpenRequest(hInet,HTTP_POST,TEXT("/form.asp"),TEXT(""),TEXT("HTTP/1.0"),0);
if(nRet==SUCCESS)
{
L_TCHAR szResponse[2048];
L_UINT32 lsize;
L_UINT uStatus;
FILE *fp;
nv[0].pszName = TEXT("email");
nv[0].pszValue =
TEXT("myemail@somewhere.com");
nv[1].pszName = TEXT("name");
nv[1].pszValue =
TEXT("First Last");
nRet=L_InetHttpSendForm(hInet,nv,2);
if(nRet!=SUCCESS)
{
MessageBox(NULL,
TEXT("Error Sending Form"), TEXT("Error"),MB_ICONEXCLAMATION);
L_InetHttpCloseRequest(hInet);
L_InetHttpDisconnect(hInet);
return;
}
L_InetHttpGetServerStatus(hInet,&uStatus);
if(uStatus==L_HTTP_STATUS_OK)
{
lsize
= 2048;
L_InetHttpGetResponse(hInet,szResponse,&lsize);
#ifdef
UNICODE
fp
= _wfopen(TEXT("output.htm"), TEXT("wb"));
#else
fp
= fopen("output.htm", "wb");
#endif
while(lsize!=0)
{
fwrite(szResponse,lsize,1,fp);
lsize
= 1048;
L_InetHttpGetResponse
(hInet,szResponse,&lsize);
}
fclose(fp);
}
else
MessageBox(NULL,TEXT("Problem
With Server"), TEXT("Error"),MB_ICONEXCLAMATION);
L_InetHttpCloseRequest(hInet);
}
L_InetHttpDisconnect(hInet);
}
}
Here is a sample form.asp that can be used with this sample.
<%@ LANGUAGE="VBSCRIPT" %>
<HTML>
<BODY>
<table>
<tr>
<td>Email:</td>
<td><% Response.Write Request("Email")%></td>
</tr>
<tr>
<td>Name:</td>
<td><% Response.Write Request("Name")%></td>
</tr>
</table>
</BODY>
<HTML>