Type Alias

nw_connection_t

A bidirectional data connection between a local endpoint and a remote endpoint.

Declaration

typedef NSObject<OS_nw_connection> *nw_connection_t;

Topics

Creating Connections

nw_connection_create

Initializes a new connection to a remote endpoint.

nw_connection_set_queue

Sets the queue on which all connection events are delivered.

nw_connection_start

Starts establishing a connection.

nw_connection_restart

Restarts a connection that is in the waiting state.

Handling State Updates

nw_connection_state_t

States indicating whether a connection can be used to send and receive data.

nw_connection_set_state_changed_handler

Sets a handler to receive connection state updates.

nw_connection_state_changed_handler_t

A handler that delivers connection state updates with associated errors.

Sending and Receiving Data

nw_connection_send

Sends data on a connection.

nw_connection_send_completion_t

A completion handler that indicates when the connection has finished processing sent content.

nw_content_context_t

A representation of a message to send or receive, containing protocol metadata and send properties.

nw_connection_receive

Schedules a single receive completion handler, with a range indicating how many bytes the handler can receive at one time.

nw_connection_receive_completion_t

A completion handler that indicates when content has been received by the connection, or that an error was encountered.

nw_connection_receive_message

Schedules a single receive completion handler for a complete message, as opposed to a range of bytes.

nw_connection_batch

Defines a block in which calls to send and receive are processed as a batch to improve performance.

nw_connection_get_maximum_datagram_size

Accesses the maximum size of a datagram message that can be sent on a connection.

Canceling Connections

nw_connection_cancel

Cancels the connection and gracefully disconnects any established network protocols.

nw_connection_force_cancel

Cancels the connection and immediately disconnects any established network protocols.

nw_connection_cancel_current_endpoint

Causes the current endpoint to be rejected, allowing the connection to try another resolved address.

Handling Path Updates

nw_connection_copy_current_path

Accesses the network path the connection is using.

nw_connection_set_path_changed_handler

Sets a handler that receives network path updates.

nw_connection_path_event_handler_t

A handler that delivers network path updates.

nw_connection_set_viability_changed_handler

Sets a handler that receives updates when data can be sent and received.

nw_connection_set_better_path_available_handler

Sets a handler that receives updates when an alternative network path is preferred over the current path.

nw_connection_boolean_event_handler_t

A handler that receives Boolean state updates from a connection, such as viability and better path state.

Collecting Connection Metrics

nw_establishment_report_t

A report that provides metrics about how a connection was established.

nw_connection_access_establishment_report

Requests a copy of the connection's establishment report once the connection is in the ready state.

nw_establishment_report_access_block_t

A block that delivers a connection's establishment report when it's in the ready state.

nw_data_transfer_report_t

A report that provides metrics about data being sent and received on a connection.

nw_connection_create_new_data_transfer_report

Begins a new data transfer report, which can later be collected.

Copying Connection State

nw_connection_copy_protocol_metadata

Retrieves the connection-wide metadata for a specific protocol.

nw_connection_copy_endpoint

Accesses the endpoint with which the connection was created.

nw_connection_copy_parameters

Accesses the parameters with which the connection was created.

nw_connection_copy_description

Copies the description of the connection as a string.

See Also

Connections and Listeners

Implementing netcat with Network Framework

Build a simple netcat tool that establishes network connections and transfers data.

nw_listener_t

An object you use to listen for incoming network connections.

nw_browser_t

An object you use to browse for available network services.

nw_ethernet_channel_t

An object you use to send and receive custom Ethernet frames.