<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Network",
  "identifier" : "/documentation/Network/NWProtocolWebSocket/CloseCode",
  "metadataVersion" : "0.1.0",
  "role" : "Enumeration",
  "symbol" : {
    "kind" : "Enumeration",
    "modules" : [
      "Network"
    ],
    "preciseIdentifier" : "s:7Network19NWProtocolWebSocketC9CloseCodeO"
  },
  "title" : "NWProtocolWebSocket.CloseCode"
}
-->

# NWProtocolWebSocket.CloseCode

Types of codes used upon closing a WebSocket connection.

```
enum CloseCode
```

## Topics

### Close Code Types

[`init(rawValue: UInt16) throws`](/documentation/Network/NWProtocolWebSocket/CloseCode/init(rawValue:))

Initializes a close code with a raw value.

[`case protocolCode(NWProtocolWebSocket.CloseCode.Defined)`](/documentation/Network/NWProtocolWebSocket/CloseCode/protocolCode(_:))

A well-known close code reserved by the protocol (values 1000-2999).

[`enum Defined`](/documentation/Network/NWProtocolWebSocket/CloseCode/Defined)

Well-known close code values.

[`case applicationCode(UInt16)`](/documentation/Network/NWProtocolWebSocket/CloseCode/applicationCode(_:))

A close code in the range reserved for applications and frameworks (3000-3999).

[`case privateCode(UInt16)`](/documentation/Network/NWProtocolWebSocket/CloseCode/privateCode(_:))

A close code in the private-use range (4000-4999).

## Relationships

### Conforms To

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

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

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

---

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)