Instance Property


A code that indicates the reason a connection closed.


var closeCode: URLSessionWebSocketTask.CloseCode { get }


You can retrieve the close code at any time. When the task is not yet closed, this value is URLSessionWebSocketTask.CloseCode.invalid.

See Also

Closing the Connection

func cancel(with: URLSessionWebSocketTask.CloseCode, reason: Data?)

Sends a close frame with the given close code and optional close reason.

enum URLSessionWebSocketTask.CloseCode

A code that indicates why a WebSocket connection closed.

var closeReason: Data?

A block of data that provides further information about why a connection closed.