<!--
{
  "availability" : [
    "iOS: 12.0.0 -",
    "iPadOS: 12.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.14.0 -",
    "tvOS: 12.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Network",
  "identifier" : "/documentation/Network/nw_ws_close_code_t",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Network"
    ],
    "preciseIdentifier" : "c:@EA@nw_ws_close_code_t"
  },
  "title" : "nw_ws_close_code_t"
}
-->

# nw_ws_close_code_t

Types of codes used upon closing a WebSocket connection.

```
struct nw_ws_close_code_t
```

## Topics

### Defined Close Codes

[`nw_ws_close_code_normal_closure`](/documentation/Network/nw_ws_close_code_normal_closure)

A normal closure occurred with no errors.

[`nw_ws_close_code_going_away`](/documentation/Network/nw_ws_close_code_going_away)

An endpoint is no longer available, such as when a server is down.

[`nw_ws_close_code_protocol_error`](/documentation/Network/nw_ws_close_code_protocol_error)

An endpoint is terminating the connection due to a protocol error.

[`nw_ws_close_code_unsupported_data`](/documentation/Network/nw_ws_close_code_unsupported_data)

An endpoint is terminating the connection because it received a type of data it cannot accept.

[`nw_ws_close_code_no_status_received`](/documentation/Network/nw_ws_close_code_no_status_received)

This value is reserved for local errors and indicates that no Close code was received.

[`nw_ws_close_code_abnormal_closure`](/documentation/Network/nw_ws_close_code_abnormal_closure)

This value is reserved for local errors and indicates that no Close message was received.

[`nw_ws_close_code_invalid_frame_payload_data`](/documentation/Network/nw_ws_close_code_invalid_frame_payload_data)

An endpoint is terminating the connection because it received data within a message that was inconsistent with the message type.

[`nw_ws_close_code_policy_violation`](/documentation/Network/nw_ws_close_code_policy_violation)

An endpoint is terminating the connection because it received a message that violates its policy.

[`nw_ws_close_code_message_too_big`](/documentation/Network/nw_ws_close_code_message_too_big)

An endpoint is terminating the connection because it received a message that is too big for it to process.

[`nw_ws_close_code_mandatory_extension`](/documentation/Network/nw_ws_close_code_mandatory_extension)

The WebSocket client expected the server to negotiate one or more extensions that were not negotiated.

[`nw_ws_close_code_internal_server_error`](/documentation/Network/nw_ws_close_code_internal_server_error)

The server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request.

[`nw_ws_close_code_tls_handshake`](/documentation/Network/nw_ws_close_code_tls_handshake)

This value is reserved for local errors and indicates that the TLS handshake failed.

## Relationships

### Conforms To

[`Sendable`](/documentation/Swift/Sendable)

[`Hashable`](/documentation/Swift/Hashable)

[`BitwiseCopyable`](/documentation/Swift/BitwiseCopyable)

[`RawRepresentable`](/documentation/Swift/RawRepresentable)

[`Equatable`](/documentation/Swift/Equatable)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)