Skip to content

MTY_WebSocketConnect

chrisd1100 edited this page May 13, 2023 · 2 revisions

Connect to a WebSocket endpoint.

MTY_WebSocket *MTY_WebSocketConnect(
    const char * url,
    const char * headers,
    const char * proxy,
    uint32_t     timeout,
    uint16_t *   upgradeStatus
);

Parameters

url (const char *)

The URL for the WebSocket, the scheme must be either ws or wss.

headers (const char *)

HTTP header key/value pairs in the format Key:Value separated by newline characters.

May be NULL for no additional headers.

proxy (const char *)

The proxy URL including the port, i.e. http://example.com:1337, or NULL to use the OS's default proxy.

timeout (uint32_t)

Time to wait in milliseconds for connection.

upgradeStatus (uint16_t *)

Set to the HTTP response status code of the WebSocket upgrade request. This value is set even on failure.

Return value

MTY_WebSocket *

On failure, NULL is returned. Call MTY_GetLog for details.

The returned MTY_WebSocket must be destroyed with MTY_WebSocketDestroy.

Platform support

Windows   macOS   Android   Linux   Web  

See also

Module: Net

Clone this wiki locally