Unicode C Requires Chilkat v11.6.0+
Unicode 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 Unicode C Downloads
#include <C_CkMcpW.h>
#include <C_CkSocketW.h>
void ChilkatSample(void)
{
BOOL success;
HCkMcpW mcp;
HCkSocketW sock;
success = FALSE;
mcp = CkMcpW_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 = CkSocketW_Create();
CkSocketW_putHttpProxyHostname(sock,L"proxy.example.com");
CkSocketW_putHttpProxyPort(sock,8080);
success = CkMcpW_SetConnectionSettings(mcp,sock);
if (success == FALSE) {
wprintf(L"%s\n",CkMcpW_lastErrorText(mcp));
CkMcpW_Dispose(mcp);
CkSocketW_Dispose(sock);
return;
}
success = CkMcpW_Connect(mcp,L"https://learn.microsoft.com/api/mcp");
if (success == FALSE) {
wprintf(L"%s\n",CkMcpW_lastErrorText(mcp));
CkMcpW_Dispose(mcp);
CkSocketW_Dispose(sock);
return;
}
wprintf(L"Connected using the configured connection settings.\n");
CkMcpW_Dispose(mcp);
CkSocketW_Dispose(sock);
}