<!--
{
  "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/NWProtocolFramerImplementation",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Network"
    ],
    "preciseIdentifier" : "s:7Network30NWProtocolFramerImplementationP"
  },
  "title" : "NWProtocolFramerImplementation"
}
-->

# NWProtocolFramerImplementation

A protocol to which your classes can conform in order to implement a custom framing protocol.

```
protocol NWProtocolFramerImplementation : AnyObject
```

## Topics

### Handling Instance Lifetime

[`init(framer: NWProtocolFramer.Instance)`](/documentation/Network/NWProtocolFramerImplementation/init(framer:))

Initializes your custom framing protocol for use in one connection attempt.

[`func start(framer: NWProtocolFramer.Instance) -> NWProtocolFramer.StartResult`](/documentation/Network/NWProtocolFramerImplementation/start(framer:))

Requests that your protocol set up its state and begin a handshake, if necessary.

[`enum StartResult`](/documentation/Network/NWProtocolFramer/StartResult)

Results that you send to indicate the disposition of your protocol after receiving the call to start.

[`func wakeup(framer: NWProtocolFramer.Instance)`](/documentation/Network/NWProtocolFramerImplementation/wakeup(framer:))

Delivers a scheduled wakeup event.

[`func stop(framer: NWProtocolFramer.Instance) -> Bool`](/documentation/Network/NWProtocolFramerImplementation/stop(framer:))

Requests that your protocol send any final messages to close the connection.

[`func cleanup(framer: NWProtocolFramer.Instance)`](/documentation/Network/NWProtocolFramerImplementation/cleanup(framer:))

Indicates that your protocol should clean up all allocations before being deallocated.

[`static var label: String`](/documentation/Network/NWProtocolFramerImplementation/label)

A label defined by your custom protocol for use in debugging.

### Handling Data

[`func handleOutput(framer: NWProtocolFramer.Instance, message: NWProtocolFramer.Message, messageLength: Int, isComplete: Bool)`](/documentation/Network/NWProtocolFramerImplementation/handleOutput(framer:message:messageLength:isComplete:))

Notifies your protocol about a new outbound message.

[`func handleInput(framer: NWProtocolFramer.Instance) -> Int`](/documentation/Network/NWProtocolFramerImplementation/handleInput(framer:))

Notifies your protocol that new inbound data is available to parse.



---

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)