TechnologiesNetworking & Connectivity

Network

iOSmacOStvOSwatchOSvisionOS

Network is a transport networking API for establishing TCP, UDP, and TLS connections across iOS, macOS, tvOS, watchOS, and visionOS. You configure connections through nw_parameters and nw_protocol_options, connect to an nw_endpoint, and drive an nw_connection through its connection states to send and receive framed messages with content contexts. The framework also supports Bonjour service discovery with nw_browser and nw_advertise_descriptor, and reports network reachability through nw_path and its path status, so you can adapt to changing interfaces and link quality. Establishment and resolution reports such as nw_establishment_report and nw_resolution_report give you visibility into how a connection was made.

Connections 6

Bidirectional transport sessions you establish to send and receive framed messages.

  • Cl
    NWConnectioniOS 12.0+
    An NWConnection is an object that represents a bi-directional data pipe between
  • Cl
    NetworkConnectioniOS 26.0+
    Connect to an endpoint on the network to send and receive data.
  • Pr
    ConnectableiOS 26.0+
    Describes types that can be used to make NetworkConnections.
  • Pr
    ConnectionStorageiOS 26.0+
    Types that conform to ConnectionStorage can be used as additional storage within
  • St
    nw_connection_state_t
    @typedef nw_connection_state_t
  • Pr
    OS_nw_connection
    The underlying object type backing a network connection.

Connection Groups and Channels 11

Grouped and link-layer transports for multicast, multiplexed, and Ethernet communication.

  • Cl
    NWConnectionGroupiOS 14.0+
    An `NWConnectionGroup` is an object that represents an active session with multiple entities
  • Cl
    NWMulticastGroupiOS 14.0+
    A `NWMulticastGroup` is a specific type of `NWGroupDescriptor` that can be used to create
  • Cl
    NWMultiplexGroupiOS 15.0+
    An `NWMultiplexGroup` is a specific type of `NWGroupDescriptor` that can be used to create
  • Cl
    NWEthernetChannel
    An Ethernet channel is an object that represents a bi-directional data channel to send
  • Cl
    NetworkChanneliOS 26.0+
    A base class supporting sending and recieving data through an arbitrary network channel.
  • Pr
    NWGroupDescriptoriOS 14.0+
    An `NWGroupDescriptor` defines a set of endpoints that can be communicated with
  • St
    nw_connection_group_state_t
    @typedef nw_connection_group_state_t
  • St
    nw_ethernet_channel_state_tmacOS 10.15+
    @typedef nw_ethernet_channel_state_t
  • Pr
    OS_nw_connection_group
    The underlying object type backing a connection group.
  • Pr
    OS_nw_group_descriptor
    The underlying object type that describes a connection group.
  • Pr
    OS_nw_ethernet_channel
    The underlying object type backing an Ethernet channel.

Listeners 6

Server-side objects that accept incoming connections and advertise services.

  • Cl
    NWListeneriOS 12.0+
    An NWListener is an object that is able to receive incoming NWConnection
  • Cl
    NetworkListeneriOS 26.0+
    Listen for incoming network connections.
  • Pr
    ListenerProvideriOS 26.0+
    Extensible support for configuring advertise descriptors to define the service a listener should advertise.
  • St
    BonjourListenerProvideriOS 26.0+
    Advertise a Bonjour service.
  • St
    nw_listener_state_t
    @typedef nw_listener_state_t
  • Pr
    OS_nw_listener
    The underlying object type backing a network listener.

Endpoints and Addresses 7

Values that identify the hosts, ports, and addresses a connection communicates with.

  • En
    NWEndpointiOS 12.0+
    A local or remote endpoint identified by host, address, or service.
  • Pr
    IPAddressiOS 12.0+
    An IP address
  • St
    IPv4AddressiOS 12.0+
    IPv4Address
  • St
    IPv6AddressiOS 12.0+
    IPv6Address
  • St
    nw_endpoint_type_t
    @typedef nw_endpoint_type_t
  • St
    UnexpectedEndpointTypeiOS 26.0+
    An error generated when an unexpected endpoint type is supplied.
  • Pr
    OS_nw_endpoint
    The underlying object type that represents a network endpoint.

Parameters and Protocol Stacks 20

Configuration that defines the protocol stack, options, and policies used to establish connections.

  • Cl
    NWParametersiOS 12.0+
    An NWParameters object contains the parameters necessary to create a network
  • St
    NWParametersBuilderiOS 26.0+
    An opaque class that is responsible for creating and configuring NWParameters based on
  • Pr
    NWParametersProvideriOS 26.0+
    Types that conform to the NWParametersProvider protocol can be used to
  • Pr
    NetworkProtocolOptionsiOS 26.0+
    A protocol describing configurable options for a network protocol.
  • Cl
    NWProtocoliOS 12.0+
    NWProtocol is an abstract superclass to which protocol implementations conform.
  • Cl
    NWProtocolDefinitioniOS 12.0+
    NWProtocolDefinition is an abstract superclass that represents the identifier of a
  • Cl
    NWProtocolOptionsiOS 12.0+
    NWProtocolOptions is an abstract superclass that represents a configuration options
  • Cl
    NWProtocolMetadataiOS 12.0+
    NWProtocolMetadata is an abstract superclass. An instance of metadata holds a set of
  • Pr
    NetworkMetadataProtocoliOS 26.0+
    Types that conform to NetworkProtocolOptions can be used
  • St
    DefaultProtocolStorageiOS 26.0+
    Storage that holds the default protocol configuration for a connection.
  • St
    nw_service_class_t
    @typedef nw_service_class_t
  • St
    nw_multipath_service_t
    @typedef nw_multipath_service_t
  • St
    nw_multipath_version_t
    @typedef nw_multipath_version_t
  • St
    nw_parameters_expired_dns_behavior_t
    @typedef nw_parameters_expired_dns_behavior_t
  • En
    nw_parameters_attribution_t
    @typedef nw_parameters_attribution_t
  • Pr
    OS_nw_parameters
    The underlying object type that holds connection parameters.
  • Pr
    OS_nw_protocol_definition
    The underlying object type that identifies a protocol in a stack.
  • Pr
    OS_nw_protocol_options
    The underlying object type that holds configurable protocol options.
  • Pr
    OS_nw_protocol_metadata
    The underlying object type that carries per-protocol message metadata.
  • Pr
    OS_nw_protocol_stack
    The underlying object type that represents an ordered stack of protocols.

Transport and Security Protocols 29

Built-in protocol implementations for TCP, UDP, IP, TLS, QUIC, and WebSocket.

  • Cl
    NWProtocolTCPiOS 12.0+
    A protocol definition and options for TCP transport connections.
  • Cl
    NWProtocolUDPiOS 12.0+
    A protocol definition and options for UDP transport connections.
  • Cl
    NWProtocolIPiOS 12.0+
    A protocol definition and options for the Internet Protocol layer.
  • Cl
    NWProtocolTLSiOS 12.0+
    A protocol definition and options for TLS-secured connections.
  • Cl
    NWProtocolQUICiOS 15.0+
    A protocol definition and options for QUIC transport connections.
  • Cl
    NWProtocolWebSocketiOS 13.0+
    NWProtocolWebSocket is the default system implementation of the WebSocket Protocol.
  • St
    TCPiOS 26.0+
    The system definition of the Transmission Control Protocol (TCP).
  • St
    UDPiOS 26.0+
    The system definition of the User Datagram Protocol (UDP).
  • St
    IPiOS 26.0+
    The system definition of the Internet Protocol (IP).
  • St
    TLSiOS 26.0+
    The system definition of the Transport Layer Security (TLS) protocol.
  • St
    QUICiOS 26.0+
    The system definition of the QUIC protocol.
  • St
    QUICStreamiOS 26.0+
    A QUIC stream that runs over a QUIC connection.
  • St
    QUICDatagramiOS 26.0+
    Send and receive unreliable datagrams over QUIC via RFC 9221
  • St
    WebSocketiOS 26.0+
    The system definition of the WebSocket protocol.
  • Pr
    StreamProtocoliOS 26.0+
    Types that conform to the StreamProtocol protocol expose methods for
  • Pr
    DatagramProtocoliOS 26.0+
    Types that conform to DatagramProtocol send and receive messages
  • Pr
    MessageProtocoliOS 26.0+
    Types that conform to MessageProtocol send and receive messages.
  • Pr
    OneToOneProtocoliOS 26.0+
    Types that conform to OneToOneProtocol are allowed to be the top protocol
  • Pr
    MultiplexProtocoliOS 26.0+
    Types that conform to MultiplexProtocol are allowed to be the top protocol
  • St
    nw_ip_version_t
    @typedef nw_ip_version_t
  • St
    nw_ip_local_address_preference_t
    @typedef nw_ip_local_address_preference_t
  • St
    nw_ip_ecn_flag_t
    @typedef nw_ip_ecn_flag_t
  • St
    nw_quic_stream_type_t
    @typedef nw_quic_stream_type_t
  • St
    nw_ws_opcode_t
    @typedef nw_ws_opcode_t
  • St
    nw_ws_close_code_t
    @typedef nw_ws_close_code_t
  • St
    nw_ws_version_t
    @typedef nw_ws_version_t
  • St
    nw_ws_response_status_t
    @typedef nw_ws_response_status_t
  • Pr
    OS_nw_ws_request
    The underlying object type that represents a WebSocket handshake request.
  • Pr
    OS_nw_ws_response
    The underlying object type that represents a WebSocket handshake response.

Custom Protocol Framing 7

Types for defining custom message framers that parse and produce application protocol data.

  • Cl
    NWProtocolFrameriOS 13.0+
    An NWProtocolFramer defines a protocol in a connection's protocol
  • Pr
    NWProtocolFramerImplementationiOS 13.0+
    NWProtocolFramerImplementation is a Swift protocol that defines an
  • St
    FrameriOS 26.0+
    An instance of a Framer protocol to load into a protocol stack.
  • Pr
    FramerProtocoliOS 26.0+
    Framer protocols allow custom framing and serialization of messages on
  • St
    TLViOS 26.0+
    A Type-Length-Value (TLV) framing protocol.
  • St
    nw_framer_start_result_t
    Constants that indicate how a custom framer should begin processing.
  • Pr
    OS_nw_framer
    The underlying object type that backs a custom protocol framer instance.

Service Discovery 13

Bonjour browsing and advertising for discovering and publishing network services.

  • Cl
    NWBrowseriOS 13.0+
    An NWBrowser discovers and tracks changes of advertised services in a local
  • Cl
    NetworkBrowseriOS 26.0+
    Discover advertised services and devices on the network.
  • Pr
    BrowserProvideriOS 26.0+
    BrowserProviders can be used when creating NetworkBrowsers.
  • St
    BonjouriOS 26.0+
    A browser that discovers Bonjour services.
  • St
    NWTXTRecordiOS 13.0+
    An NWTXTRecord is used to provide additional information about a service
  • St
    TXTRecordDecoderiOS 18.0+
    A decoder that reads values from a Bonjour TXT record.
  • St
    nw_browser_state_t
    @typedef nw_browser_state_t
  • Pr
    OS_nw_browser
    The underlying object type backing a network service browser.
  • Pr
    OS_nw_browse_descriptor
    The underlying object type that describes a service to browse for.
  • Pr
    OS_nw_browse_result
    The underlying object type that represents a discovered service.
  • Pr
    OS_nw_advertise_descriptor
    The underlying object type that describes a service to advertise.
  • Pr
    OS_nw_txt_record
    The underlying object type backing a Bonjour TXT record.
  • St
    nw_txt_record_find_key_t
    @typedef nw_txt_record_find_key_t

Path Monitoring and Interfaces 11

Reporting on network reachability, available interfaces, and link quality.

  • Cl
    NWPathMonitoriOS 12.0+
    The NWPathMonitor allows the caller to fetch the current global path (or
  • St
    NWPathiOS 12.0+
    An NWPath object represents a snapshot of network path state. This state
  • St
    NWInterfaceiOS 12.0+
    An NWInterface object represents an instance of a network interface of a specific
  • St
    nw_path_status_t
    @typedef nw_path_status_t
  • St
    nw_path_unsatisfied_reason_t
    @typedef nw_path_unsatisfied_reason_t
  • St
    nw_link_quality_t
    @typedef nw_link_quality_t
  • St
    nw_interface_type_t
    @typedef nw_interface_type_t
  • St
    nw_interface_radio_type_t
    @typedef nw_interface_radio_type_t
  • Pr
    OS_nw_path
    The underlying object type that represents a network path.
  • Pr
    OS_nw_path_monitor
    The underlying object type backing a network path monitor.
  • Pr
    OS_nw_interface
    The underlying object type that represents a network interface.

Codable Messaging 8

Coders that encode and decode Codable values for framed network messages.

  • Pr
    NetworkCoderiOS 26.0+
    A protocol for coders that encode and decode Codable network messages.
  • Pr
    NetworkEncoderiOS 26.0+
    A type that conforms to the NetworkEncoder protocol can encode a Encodable object
  • Pr
    NetworkDecoderiOS 26.0+
    A type that conforms to the NetworkEncoder protocol can decode data to an Encodable object
  • St
    CoderiOS 26.0+
    A protocol that frames and encodes/decodes Codable types.
  • St
    NetworkJSONCoderiOS 26.0+
    A coder that encodes and decodes network messages as JSON.
  • St
    NetworkPropertyListCoderiOS 26.0+
    A coder that encodes and decodes network messages as property lists.
  • Pr
    NetworkFixedWidthIntegeriOS 26.0+
    A protocol for fixed-width integers usable in network message coding.
  • Pr
    OS_nw_content_context
    The underlying object type that frames a message's content and metadata.

Connection Reports 6

Diagnostic reports describing how connections were established, resolved, and used.

  • St
    nw_data_transfer_report_state_t
    @typedef nw_data_transfer_report_state_t
  • St
    nw_report_resolution_source_t
    @typedef nw_report_resolution_source_t
  • St
    nw_report_resolution_protocol_t
    @typedef nw_report_resolution_protocol_t
  • Pr
    OS_nw_establishment_report
    The underlying object type that reports how a connection was established.
  • Pr
    OS_nw_resolution_report
    The underlying object type that reports how an endpoint was resolved.
  • Pr
    OS_nw_data_transfer_report
    The underlying object type that reports data-transfer statistics for a connection.

Privacy and Proxy Configuration 5

Configuration for DNS resolution, proxies, relays, and privacy contexts.

  • St
    ProxyConfigurationiOS 17.0+
    A ProxyConfiguration object stores a proxy configuration. Proxy configurations can be added to a Privacy Context
  • Pr
    OS_nw_resolver_config
    The underlying object type that configures DNS resolution.
  • Pr
    OS_nw_proxy_config
    The underlying object type that configures a network proxy.
  • Pr
    OS_nw_relay_hop
    The underlying object type that describes a relay hop in a connection path.
  • Pr
    OS_nw_privacy_context
    The underlying object type that defines a privacy context for connections.

Errors 3

Error types and domains reported by Network framework operations.

  • En
    NWErroriOS 12.0+
    NWError is a type to deliver error codes relevant to NWConnection and NWListener objects.
  • St
    nw_error_domain_t
    @typedef nw_error_domain_t
  • Pr
    OS_nw_error
    The underlying object type that represents a Network framework error.

Foundational Protocols 1

Base protocols shared by the framework's underlying object types.

  • Pr
    OS_nw_object
    The base protocol shared by all underlying Network framework object types.

Structures 2

  • St
    ProtocolMetadataBuilderiOS 26.0+
    A resultBuilder for configuring metadata in send methods in a declarative
  • St
    ProtocolStackBuilderiOS 26.0+
    A resultBuilder for specifying and configuring protocol stacks in

Type Aliases 87

  • Ty
    nw_object_t
  • Ty
    nw_txt_record_t
  • Ty
    nw_txt_record_access_key_t
    @typedef nw_txt_record_access_key_t
  • Ty
    nw_txt_record_access_bytes_t
    @typedef nw_txt_record_access_bytes_t
  • Ty
    nw_txt_record_applier_t
    @typedef nw_txt_record_applier_t
  • Ty
    nw_advertise_descriptor_t
  • Ty
    nw_protocol_definition_t
  • Ty
    nw_protocol_options_t
  • Ty
    nw_protocol_metadata_t
  • Ty
    nw_interface_t
  • Ty
    nw_endpoint_t
  • Ty
    nw_resolver_config_t
  • Ty
    nw_proxy_config_t
  • Ty
    nw_relay_hop_t
  • Ty
    nw_proxy_domain_enumerator_t
  • Ty
    nw_privacy_context_t
Show 71 more
  • Ty
    nw_parameters_t
  • Ty
    nw_protocol_stack_t
  • Ty
    nw_parameters_configure_protocol_block_t
  • Ty
    nw_parameters_iterate_interfaces_block_t
  • Ty
    nw_parameters_iterate_interface_types_block_t
  • Ty
    nw_protocol_stack_iterate_protocols_block_t
  • Ty
    nw_browse_descriptor_t
  • Ty
    nw_browse_result_t
  • Ty
    nw_browse_result_change_t
    @typedef nw_browse_result_change_t
  • Ty
    nw_browse_result_enumerate_interface_t
    @typedef nw_browse_result_enumerate_interface_t
  • Ty
    nw_error_t
  • Ty
    nw_browser_t
  • Ty
    nw_browser_browse_results_changed_handler_t
    @typedef nw_browser_browse_results_changed_handler_t
  • Ty
    nw_browser_state_changed_handler_t
    @typedef nw_browser_state_changed_handler_t
  • Ty
    nw_path_t
  • Ty
    nw_path_enumerate_interfaces_block_t
  • Ty
    nw_path_enumerate_gateways_block_t
  • Ty
    nw_content_context_t
  • Ty
    nw_connection_t
  • Ty
    nw_connection_state_changed_handler_t
  • Ty
    nw_connection_boolean_event_handler_t
  • Ty
    nw_connection_path_event_handler_t
  • Ty
    nw_connection_receive_completion_t
    @typedef nw_connection_receive_completion_t
  • Ty
    nw_connection_send_completion_t
    @typedef nw_connection_send_completion_t
  • Ty
    nw_group_descriptor_t
  • Ty
    nw_group_descriptor_enumerate_endpoints_block_t
    @typedef nw_group_descriptor_enumerate_endpoints_block_t
  • Ty
    nw_connection_group_t
  • Ty
    nw_connection_group_state_changed_handler_t
    @typedef nw_connection_group_state_changed_handler_t
  • Ty
    nw_connection_group_receive_handler_t
    @typedef nw_connection_group_receive_handler_t
  • Ty
    nw_connection_group_send_completion_t
    @typedef nw_connection_group_send_completion_t
  • Ty
    nw_connection_group_new_connection_handler_t
    @typedef nw_connection_group_new_connection_handler_t
  • Ty
    nw_establishment_report_t
  • Ty
    nw_establishment_report_access_block_t
  • Ty
    nw_resolution_report_t
  • Ty
    nw_report_resolution_enumerator_t
  • Ty
    nw_report_resolution_report_enumerator_t
  • Ty
    nw_report_protocol_enumerator_t
  • Ty
    nw_data_transfer_report_t
  • Ty
    nw_data_transfer_report_collect_block_t
  • Ty
    nw_ethernet_channel_t
  • Ty
    nw_ethernet_channel_state_changed_handler_t
    @typedef nw_ethernet_channel_state_changed_handler_t
  • Ty
    nw_ethernet_address_t
    @typedef nw_ethernet_address_t
  • Ty
    nw_ethernet_channel_receive_handler_t
    @typedef nw_ethernet_channel_receive_handler_t
  • Ty
    nw_ethernet_channel_send_completion_t
    @typedef nw_ethernet_channel_send_completion_t
  • Ty
    nw_framer_t
  • Ty
    nw_framer_message_t
    @typedef nw_framer_message_t
  • Ty
    nw_framer_message_dispose_value_t
    @typedef nw_framer_message_dispose_value_t
  • Ty
    nw_framer_start_handler_t
    @typedef nw_framer_start_result_t
  • Ty
    nw_framer_input_handler_t
    @typedef nw_framer_input_handler_t
  • Ty
    nw_framer_output_handler_t
    @typedef nw_framer_output_handler_t
  • Ty
    nw_framer_wakeup_handler_t
    @typedef nw_framer_wakeup_handler_t
  • Ty
    nw_framer_stop_handler_t
    @typedef nw_framer_stop_handler_t
  • Ty
    nw_framer_cleanup_handler_t
    @typedef nw_framer_cleanup_handler_t
  • Ty
    nw_framer_parse_completion_t
    @typedef nw_framer_parse_completion_t
  • Ty
    nw_framer_block_t
    @typedef nw_framer_block_t
  • Ty
    nw_listener_t
  • Ty
    nw_listener_state_changed_handler_t
  • Ty
    nw_listener_new_connection_handler_t
    @typedef nw_listener_new_connection_handler_t
  • Ty
    nw_listener_new_connection_group_handler_t
    @typedef nw_listener_new_connection_group_handler_t
  • Ty
    nw_listener_advertised_endpoint_changed_handler_t
    @typedef nw_listener_advertised_endpoint_changed_handler_t
  • Ty
    nw_path_monitor_t
  • Ty
    nw_path_monitor_cancel_handler_t
    @typedef nw_path_monitor_cancel_handler_t
  • Ty
    nw_path_monitor_update_handler_t
    @typedef nw_path_monitor_update_handler_t
  • Ty
    nw_ws_pong_handler_t
    @typedef nw_ws_pong_handler_t
  • Ty
    nw_ws_request_t
  • Ty
    nw_ws_subprotocol_enumerator_t
    @typedef nw_ws_subprotocol_enumerator_t
  • Ty
    nw_ws_additional_header_enumerator_t
    @typedef nw_ws_additional_header_enumerator_t
  • Ty
    nw_ws_response_t
  • Ty
    nw_ws_client_request_handler_t
    @typedef nw_ws_client_request_handler_t
  • Ty
    NetworkActorInterruptionHandler
    A handler that is invoked when the underlying connection is interrupted. An attempt at creating
  • Ty
    NetworkActorInvalidationHandler
    TODO: Do we need this stuff anymore...?

Extends 13

UInt8UInt16UInt32UInt64Int8Int16Int32Int64JSONEncoderPropertyListEncoderJSONDecoderPropertyListDecoderURLSessionConfiguration
← Networking & Connectivity