HttpConnect

Starts a new HTTP connection to the specified server.

Syntax

    #include <httpexp.h>
    #include <httpclnt.h> 
     
    HINTERNET HttpConnect (
       HINTERNET   hndl,
       char       *pServerName,
       UINT32      serverPort,
       UINT32      flags,
       UINT32     *pFailureReasonCode);
    

Parameters

hndl
(IN) Specifies the HTTP stack handle returned by the HttpClientOpen function.
pServerName
(IN) Points to an ASCIIZ string of the server name in either DNS or IP address format.
serverPort
(IN) Specifies the port number of the remote server. This number must be an unsigned integer.
flags
(IN) Reserved for future use. Set to 0.
pFailureReasonCode
(OUT) Points to an error code, if the connection fails to start. If the connection start is successful, returns 0.

Return Values

If successful, returns an HTTP client connection handle. Otherwise, returns NULL.

On failure, the pFailureReasonCode parameter returns one of the following values:

Decimal

Name

Description

1

ERR_INSUFFICIENT_SPACE

Insufficient memory to perform the operation.

168

ERR_ACCESS_DENIED

Insufficient permission to perform the operation.

255

ERR_BAD_PARAMETER

An invalid parameter was passed to the function.

Remarks

The HttpConnect function validates the connection information. This information, along with some other information, is stored in the handle. The actual connection is not made until an HttpSendRequest or HttpGetReply call is made.

The HttpConnect function must be followed by an HttpOpenRequest call, which allows you to format the request.

See Also