<!--
{
  "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

[`var nw_ws_close_code_normal_closure: nw_ws_close_code_t`](/documentation/Network/nw_ws_close_code_normal_closure)

A normal closure occurred with no errors.

[`var nw_ws_close_code_going_away: nw_ws_close_code_t`](/documentation/Network/nw_ws_close_code_going_away)

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

[`var nw_ws_close_code_protocol_error: nw_ws_close_code_t`](/documentation/Network/nw_ws_close_code_protocol_error)

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

[`var nw_ws_close_code_unsupported_data: nw_ws_close_code_t`](/documentation/Network/nw_ws_close_code_unsupported_data)

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

[`var nw_ws_close_code_no_status_received: nw_ws_close_code_t`](/documentation/Network/nw_ws_close_code_no_status_received)

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

[`var nw_ws_close_code_abnormal_closure: nw_ws_close_code_t`](/documentation/Network/nw_ws_close_code_abnormal_closure)

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

[`var nw_ws_close_code_invalid_frame_payload_data: nw_ws_close_code_t`](/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.

[`var nw_ws_close_code_policy_violation: nw_ws_close_code_t`](/documentation/Network/nw_ws_close_code_policy_violation)

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

[`var nw_ws_close_code_message_too_big: nw_ws_close_code_t`](/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.

[`var nw_ws_close_code_mandatory_extension: nw_ws_close_code_t`](/documentation/Network/nw_ws_close_code_mandatory_extension)

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

[`var nw_ws_close_code_internal_server_error: nw_ws_close_code_t`](/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.

[`var nw_ws_close_code_tls_handshake: nw_ws_close_code_t`](/documentation/Network/nw_ws_close_code_tls_handshake)

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

### Initializers

[`init(UInt32)`](/documentation/Network/nw_ws_close_code_t/init(_:))

[`init(rawValue: UInt32)`](/documentation/Network/nw_ws_close_code_t/init(rawValue:))

### Instance Properties

[`var rawValue: UInt32`](/documentation/Network/nw_ws_close_code_t/rawValue)

## Relationships

### Conforms To

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

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

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

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

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

---

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)