<!--
{
  "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/NWProtocolFramer/Instance",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Network"
    ],
    "preciseIdentifier" : "s:7Network16NWProtocolFramerC8InstanceC"
  },
  "title" : "NWProtocolFramer.Instance"
}
-->

# NWProtocolFramer.Instance

An object that represents a single instance of your custom protocol running in a connection.

```
final class Instance
```

## Overview

All interaction between your protocol and the connection occurs through this object.

## Topics

### Writing Output

[`func parseOutput(minimumIncompleteLength: Int, maximumLength: Int, parse: (UnsafeMutableRawBufferPointer?, Bool) -> Int) -> Bool`](/documentation/Network/NWProtocolFramer/Instance/parseOutput(minimumIncompleteLength:maximumLength:parse:))

Examines the content of output data while inside your output handler.

[`func writeOutput(data: Data)`](/documentation/Network/NWProtocolFramer/Instance/writeOutput(data:)-ydvk)

Sends arbitrary output data from your protocol to the next protocol.

[`func writeOutputNoCopy(length: Int) throws`](/documentation/Network/NWProtocolFramer/Instance/writeOutputNoCopy(length:))

Sends a specific number of bytes from a message while inside your output handler.

[`func passThroughOutput()`](/documentation/Network/NWProtocolFramer/Instance/passThroughOutput())

Indicates that your protocol no longer needs to handle output data.

### Delivering Input

[`func parseInput(minimumIncompleteLength: Int, maximumLength: Int, parse: (UnsafeMutableRawBufferPointer?, Bool) -> Int) -> Bool`](/documentation/Network/NWProtocolFramer/Instance/parseInput(minimumIncompleteLength:maximumLength:parse:))

Examines the content of input data while in your input handler.

[`func deliverInput(data: Data, message: NWProtocolFramer.Message, isComplete: Bool)`](/documentation/Network/NWProtocolFramer/Instance/deliverInput(data:message:isComplete:))

Delivers an inbound message containing arbitrary data from your protocol to the application.

[`func deliverInputNoCopy(length: Int, message: NWProtocolFramer.Message, isComplete: Bool) -> Bool`](/documentation/Network/NWProtocolFramer/Instance/deliverInputNoCopy(length:message:isComplete:))

Delivers an inbound message containing a specific number of next received bytes.

[`func passThroughInput()`](/documentation/Network/NWProtocolFramer/Instance/passThroughInput())

Indicates that your protocol no longer needs to handle input data.

### Managing Instance Lifetime

[`func markReady()`](/documentation/Network/NWProtocolFramer/Instance/markReady())

Indicates to a connection that your protocol’s handshake is complete.

[`func markFailed(error: NWError?)`](/documentation/Network/NWProtocolFramer/Instance/markFailed(error:))

Indicates to a connection that your protocol has encountered an error, or has gracefully closed.

[`func prependApplicationProtocol(options: NWProtocolOptions) throws`](/documentation/Network/NWProtocolFramer/Instance/prependApplicationProtocol(options:))

Dynamically adds another protocol that will run above your protocol after your protocol calls [`markReady()`](/documentation/Network/NWProtocolFramer/Instance/markReady()).

### Inspecting Instance Properties

[`var remote: NWEndpoint?`](/documentation/Network/NWProtocolFramer/Instance/remote)

The remote endpoint of the connection in which your protocol is running.

[`var local: NWEndpoint?`](/documentation/Network/NWProtocolFramer/Instance/local)

The local endpoint of the connection in which your protocol is running.

[`var parameters: NWParameters?`](/documentation/Network/NWProtocolFramer/Instance/parameters)

The parameters of the connection in which your protocol is running.

### Handling Asynchronous Events

[`func async(execute: () -> Void)`](/documentation/Network/NWProtocolFramer/Instance/async(execute:))

Requests that a block be executed on the connection’s internal scheduling context.

[`func scheduleWakeup(wakeupTime: NWProtocolFramer.Instance.WakeupTime)`](/documentation/Network/NWProtocolFramer/Instance/scheduleWakeup(wakeupTime:))

Requests that [`wakeup(framer:)`](/documentation/Network/NWProtocolFramerImplementation/wakeup(framer:)) be called on your protocol at a specific time in the future.

[`enum WakeupTime`](/documentation/Network/NWProtocolFramer/Instance/WakeupTime)

Times at which to schedule a protocol wakeup.

### Instance Properties

[`var options: NWProtocolFramer.Options`](/documentation/Network/NWProtocolFramer/Instance/options)

### Instance Methods

[`func prependApplicationProtocolIgnoringReady(options: NWProtocolOptions) throws`](/documentation/Network/NWProtocolFramer/Instance/prependApplicationProtocolIgnoringReady(options:))

Dynamically add a protocol to a connection establishment
attempt “above” the framer protocol. This means that the
protocol above will start running once the framer becomes
ready by calling markReady(). This can only
be used with framers that return a value of
willMarkReady to their start
handlers. An example of using this functionality is
adding a security protocol, like TLS, above a framer
once that framer completes its initial handshake.

[`func writeOutput<Output>(data: Output)`](/documentation/Network/NWProtocolFramer/Instance/writeOutput(data:)-9axn3)

## Relationships

### Conforms To

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

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

[`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)