<!--
{
  "documentType" : "article",
  "framework" : "Network",
  "identifier" : "/documentation/Network/framer-protocol-options",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Framer Protocol Options"
}
-->

# Framer Protocol Options

Create custom protocols to frame applications messages over a connection.

## Topics

### Adding Framers to Connections

[`nw_framer_create_definition`](/documentation/Network/nw_framer_create_definition(_:_:_:))

Initializes a new protocol definition based on your protocol implementation.

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

A handler that represents the entry point into your custom protocol.

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

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

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

Results that you send to indicate the disposition of your protocol after the start handler is invoked.

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

A constant flag value that indicates that the default framer protocol behavior should be used.

[`nw_framer_create_options`](/documentation/Network/nw_framer_create_options(_:))

Initializes a set of protocol options with a custom framer definition.

### Handling Output Data

[`nw_framer_set_output_handler`](/documentation/Network/nw_framer_set_output_handler(_:_:))

Sets a block to handle new outbound messages.

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

A handler that notifies your protocol about a new outbound message.

[`nw_framer_parse_output`](/documentation/Network/nw_framer_parse_output(_:_:_:_:_:))

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

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

A handler that examines a range of data being sent or received.

[`nw_framer_write_output`](/documentation/Network/nw_framer_write_output(_:_:_:))

Sends arbitrary output data in a buffer from your protocol to the next protocol.

[`nw_framer_write_output_data`](/documentation/Network/nw_framer_write_output_data(_:_:))

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

[`nw_framer_write_output_no_copy`](/documentation/Network/nw_framer_write_output_no_copy(_:_:))

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

[`nw_framer_pass_through_output`](/documentation/Network/nw_framer_pass_through_output(_:))

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

### Handling Input Data

[`nw_framer_set_input_handler`](/documentation/Network/nw_framer_set_input_handler(_:_:))

Sets a block to handle new inbound data.

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

A handler that notifies your protocol that new inbound data is available to parse.

[`nw_framer_parse_input`](/documentation/Network/nw_framer_parse_input(_:_:_:_:_:))

Examines the content of input data while inside your input handler block.

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

A handler that examines a range of data being sent or received.

[`nw_framer_deliver_input`](/documentation/Network/nw_framer_deliver_input(_:_:_:_:_:))

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

[`nw_framer_deliver_input_no_copy`](/documentation/Network/nw_framer_deliver_input_no_copy(_:_:_:_:))

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

[`nw_framer_pass_through_input`](/documentation/Network/nw_framer_pass_through_input(_:))

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

### Customizing Framer Messages

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

A message for a custom protocol, in which you can store arbitrary key-value pairs.

[`nw_protocol_metadata_is_framer_message`](/documentation/Network/nw_protocol_metadata_is_framer_message(_:))

Checks if a metadata object represents a custom framer protocol message.

[`nw_framer_protocol_create_message`](/documentation/Network/nw_framer_protocol_create_message(_:))

Initializes an empty message for a custom framer definition.

[`nw_framer_message_create`](/documentation/Network/nw_framer_message_create(_:))

Initializes an empty message from within a framer implementation.

[`nw_framer_message_set_value`](/documentation/Network/nw_framer_message_set_value(_:_:_:_:))

Sets a value to be stored in a framer message, with a completion to call to disposed the stored value when the message is released.

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

A handler that’s invoked when your custom value needs to be released due to a message being released or the value being replaced.

[`nw_framer_message_set_object_value`](/documentation/Network/nw_framer_message_set_object_value(_:_:_:))

Sets an NSObject value to be stored in a framer message.

[`nw_framer_message_access_value`](/documentation/Network/nw_framer_message_access_value(_:_:_:))

Accesses a custom value stored in a framer message.

[`nw_framer_message_copy_object_value`](/documentation/Network/nw_framer_message_copy_object_value(_:_:))

Accesses an NSObject value stored in a framer message.

### Managing Instance Lifetime

[`nw_framer_mark_ready`](/documentation/Network/nw_framer_mark_ready(_:))

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

[`nw_framer_mark_failed_with_error`](/documentation/Network/nw_framer_mark_failed_with_error(_:_:))

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

[`nw_framer_prepend_application_protocol`](/documentation/Network/nw_framer_prepend_application_protocol(_:_:))

Dynamically adds another protocol that will run above your protocol after your protocol calls [`nw_framer_mark_ready(_:)`](/documentation/Network/nw_framer_mark_ready(_:)).

[`nw_framer_set_stop_handler`](/documentation/Network/nw_framer_set_stop_handler(_:_:))

Sets a block to handle when the connection is being closed.

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

A handler that requests that your protocol send any final messages to close the connection.

[`nw_framer_set_cleanup_handler`](/documentation/Network/nw_framer_set_cleanup_handler(_:_:))

Sets a block to handle the final cleanup of allocations made by your protocol instance.

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

A handler that tells your protocol to clean up all allocations before being deallocated.

### Inspecting Instance Properties

[`nw_framer_copy_remote_endpoint`](/documentation/Network/nw_framer_copy_remote_endpoint(_:))

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

[`nw_framer_copy_local_endpoint`](/documentation/Network/nw_framer_copy_local_endpoint(_:))

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

[`nw_framer_copy_parameters`](/documentation/Network/nw_framer_copy_parameters(_:))

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

### Handling Asynchronous Events

[`nw_framer_schedule_wakeup`](/documentation/Network/nw_framer_schedule_wakeup(_:_:))

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

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

A sentinel value that indicates that no wakeup should be delivered.

[`nw_framer_set_wakeup_handler`](/documentation/Network/nw_framer_set_wakeup_handler(_:_:))

Sets a handler to receive scheduled wakeup events.

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

A handler that delivers a scheduled wakeup event.

[`nw_framer_async`](/documentation/Network/nw_framer_async(_:_:))

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

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

A block to be invoked asynchronously on your framer protocol’s scheduling context.



---

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)