WINHTTP_CONNECTION_INFO structure (winhttp.h)

The WINHTTP_CONNECTION_INFO structure contains the source and destination IP address of the request that generated the response.

Syntax

typedef struct _WINHTTP_CONNECTION_INFO {
  DWORD            cbSize;
  SOCKADDR_STORAGE LocalAddress;
  SOCKADDR_STORAGE RemoteAddress;
} WINHTTP_CONNECTION_INFO, *PWINHTTP_CONNECTION_INFO;

Members

cbSize

The size, in bytes, of the WINHTTP_CONNECTION_INFO structure.

LocalAddress

A SOCKADDR_STORAGE structure that contains the local IP address and port of the original request.

RemoteAddress

A SOCKADDR_STORAGE structure that contains the remote IP address and port of the original request.

Remarks

When WinHttpReceiveResponse returns, the application can retrieve the source and destination IP address of the request that generated the response. The application calls WinHttpQueryOption with the WINHTTP_OPTION_CONNECTION_INFO option, and provides the WINHTTP_CONNECTION_INFO structure in the lpBuffer parameter.

Examples

The following code example shows the call to WinHttpQueryOption. Winsock2.h must be included before Winhttp.h when using the WINHTTP_OPTION_CONNECTION_INFO option.

If the original request was redirected, the WINHTTP_CONNECTION_INFO structure contains the IP address and port of the request that resulted from the first non-30X response.

WINHTTP_CONNECTION_INFO ConnInfo;
DWORD dwConnInfoSize = sizeof(WINHTTP_CONNECTION_INFO);

WinHttpQueryOption( hRequest,
                    WINHTTP_OPTION_CONNECTION_INFO,
                    &ConnInfo,
                    &dwConnInfoSize);

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Header winhttp.h