LInet::Connect
#include "ltwrappr.h"
virtual L_INT LInet::Connect(pszAddress, nPort)
/* address of the computer to which to connect */ | |
L_INT nPort; |
/* port on remote computer to which to connect */ |
Connects to a remote computer.
Parameter |
Description |
pszAddress |
Character string containing the address of the computer to which you want to connect |
nPort |
Port on the remote computer to which to connect |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
This function requests a connection to a remote computer. The remote computer must accept the connection by calling LInet::AcceptConnect.
pszAddress can be any URL or an IP address in the Internet dot notation. Ex. http://www.leadtools.com or 207.238.49.130.
A call to LInet::OnConnect will be generated when a connection request is successfully accepted by the remote computer.
You must initialize the LEADTOOLS Internet DLL using LInet::StartUp before calling this function.
Required DLLs and Libraries
LTNET 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
// the user should derive a class from LInet to support the OnConnect callback function
// suppose it was named as LUserInet
LUserInet UserInet;
UserInet.StartUp();
// connect to LEAD.
UserInet.Connect("207.238.49.190", 1000);
// other operations
UserInet.ShutDown();
L_INT LUserInet::OnConnect(LInet L_FAR *plConnection, L_INT nError)
{
L_CHAR *pName;
L_INT nRet = SUCCESS;
L_TCHAR szString[150] = TEXT("\0");
if (nError != SUCCESS)
return nError;
// retreive the remote computer name
if ((pName = plConnection->GetHostName(HOST_NAME_IP)) == NULL)
return FAILURE;
wsprintf(szString, TEXT("You have successfully connected to %s"), pName);
MessageBox(NULL, szString, TEXT(""), MB_OK);
// other operations
// close the connection
Close(plConnection);
return nRet;
}