Class

NWUDPSession

An object to manage a UDP session to a network endpoint.

Declaration

@interface NWUDPSession : NSObject

Overview

Since UDP does not include a handshake with the remote endpoint as part of its protocol, it is up to the client of the UDP session to provide feedback on the viability of the current endpoint. If a session is opened to a hostname, the system will resolve that hostname into potentially several IP addresses. Once the session state is NWUDPSessionStateReady, the client should try to write and read datagrams. If there is no response from the remote endpoint, the client can try the next address that was resolved using tryNextResolvedEndpoint.

Topics

Monitoring the Session State

state

The current state of the UDP session

viable

The viability of a UDP session represents whether or not data can be transferred

Selecting Remote Endpoints

resolvedEndpoint

The currently targeted remote endpoint.

- tryNextResolvedEndpoint

Mark the current value of resolvedEndpoint as unusable, and try to switch to the next available endpoint

Transferring Data

- setReadHandler:maxDatagrams:

Set a read handler for datagrams

maximumDatagramLength

The maximum size of a datagram to be written currently

Canceling the Session

- cancel

Cancel the session

Responding to Network Changes

hasBetterPath

If a session has a better path, new session would use a different interface

- initWithUpgradeForSession:

This convenience initializer can be used to create a new session based on the original session’s endpoint and parameters.

Getting Session Properties

endpoint

The destination endpoint with which this session was created

currentPath

The current evaluated path for the session’s resolvedEndpoint property.

Relationships

Inherits From