C Requires Chilkat v11.6.0+
C
Configure MCP Connection Settings
See more MCP Client Examples
Demonstrates Mcp.SetConnectionSettings, which copies connection settings -- such as an HTTP proxy, SOCKS proxy, bind IP address, and TLS options -- from a Socket and applies them before connecting.
Background. This is optional; if not used, a direct connection is made. It is useful when the MCP server must be reached through a proxy or with specific TLS settings.
Chilkat C Downloads
#include <C_CkMcp.h>
#include <C_CkSocket.h>
void ChilkatSample(void)
{
BOOL success;
HCkMcp mcp;
HCkSocket sock;
success = FALSE;
mcp = CkMcp_Create();
// Configure connection settings on a Socket -- such as an HTTP proxy, SOCKS proxy, bind IP address,
// or TLS options -- and apply them to the MCP client before connecting. This is optional; if not
// used, a direct connection is made.
sock = CkSocket_Create();
CkSocket_putHttpProxyHostname(sock,"proxy.example.com");
CkSocket_putHttpProxyPort(sock,8080);
success = CkMcp_SetConnectionSettings(mcp,sock);
if (success == FALSE) {
printf("%s\n",CkMcp_lastErrorText(mcp));
CkMcp_Dispose(mcp);
CkSocket_Dispose(sock);
return;
}
success = CkMcp_Connect(mcp,"https://learn.microsoft.com/api/mcp");
if (success == FALSE) {
printf("%s\n",CkMcp_lastErrorText(mcp));
CkMcp_Dispose(mcp);
CkSocket_Dispose(sock);
return;
}
printf("Connected using the configured connection settings.\n");
CkMcp_Dispose(mcp);
CkSocket_Dispose(sock);
}