One Logo Pool Ball
Network · IOS API REFERENCE

WebSocket

struct · iOS 26.0+ · SDK 27.1

struct WebSocket

The system definition of the WebSocket protocol. Can be used to add WebSocket to a protocol stack and configure its options.

Members (5)

method · iOS 26.0+

subprotocols

TypeScript
subprotocols(subprotocols: Array<string>): WebSocket
Swift declaration
func subprotocols(_ subprotocols: [String]) -> WebSocket

Set the list of supported application protocols that will be presented to a WebSocket server during connection establishment. > Note: This function will only take effect on WebSocket clients. - Parameter subprotocols: An array of subprotocol strings.

method · iOS 26.0+

autoReplyPing

TypeScript
autoReplyPing(reply: boolean): WebSocket
Swift declaration
func autoReplyPing(_ reply: Bool) -> WebSocket

Configure the WebSocket protocol to automatically reply to pings. - Parameter reply: If true, ping messages will automatically be consumed by the connection instead of being delivered to the . Defaults to false.

method · iOS 26.0+

skipHandshake

TypeScript
skipHandshake(skip: boolean): WebSocket
Swift declaration
func skipHandshake(_ skip: Bool) -> WebSocket

Configure the WebSocket protocol to skip the opening handshake and begin framing data as soon as the underlying connection is established. > Note: This option should not be set when communicating with a generic WebSocket server or client. This option allows a custom handshake (or no handshake) to be implemented below the WebSocket layer when both client and server are coordinated. - Parameter skip: True to skip the handshake. Defaults to false.

method · iOS 26.0+

additionalHeaders

TypeScript
additionalHeaders(headers: Array<{ "name": string; "value": string }>): WebSocket
Swift declaration
func additionalHeaders(_ headers: [(name: String, value: String)]) -> WebSocket

Set additional HTTP header fields to be sent by the client during the WebSocket handshake. This can be used for custom protocols and cookies. Multiple headers of the same name are not allowed, and the header will replaced by the most recently set value. > Note: This function will only take effect on WebSocket clients. - Parameter headers: An array of HTTP header field names and values.

method · iOS 26.0+

maximumMessageSize

TypeScript
maximumMessageSize(size: number): WebSocket
Swift declaration
func maximumMessageSize(_ size: Int) -> WebSocket

Set the maximum allowed message size to be received by the WebSocket connection. This does not limit the sending message size. A maximum message size of 0 means there is no receive limit. The default maximum message size is 0. - Parameter size: The maximum message size.

Skipped declarations

2 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

WebSocket.init(_:)

This declaration needs Swift generic type arguments. (no canonical witness for BelowProtocol)

WebSocket.init(_:)

This declaration needs Swift generic type arguments. (no canonical witness for BelowProtocol)

All Network types →