---
title: NWUDPSession
framework: networkextension
role: symbol
role_heading: Class
path: networkextension/nwudpsession
---

# NWUDPSession

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

## Declaration

```swift
class NWUDPSession
```

## Overview

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](networkextension/nwudpsession/state.md)
- [NWUDPSessionState](networkextension/nwudpsessionstate.md)
- [isViable](networkextension/nwudpsession/isviable.md)

### Selecting remote endpoints

- [resolvedEndpoint](networkextension/nwudpsession/resolvedendpoint.md)
- [tryNextResolvedEndpoint()](networkextension/nwudpsession/trynextresolvedendpoint().md)

### Transferring data

- [setReadHandler(_:maxDatagrams:)](networkextension/nwudpsession/setreadhandler(_:maxdatagrams:).md)
- [writeDatagram(_:completionHandler:)](networkextension/nwudpsession/writedatagram(_:completionhandler:).md)
- [writeMultipleDatagrams(_:completionHandler:)](networkextension/nwudpsession/writemultipledatagrams(_:completionhandler:).md)
- [maximumDatagramLength](networkextension/nwudpsession/maximumdatagramlength.md)

### Canceling the session

- [cancel()](networkextension/nwudpsession/cancel().md)

### Responding to network changes

- [hasBetterPath](networkextension/nwudpsession/hasbetterpath.md)
- [init(upgradeFor:)](networkextension/nwudpsession/init(upgradefor:).md)

### Getting session properties

- [endpoint](networkextension/nwudpsession/endpoint.md)
- [currentPath](networkextension/nwudpsession/currentpath.md)

### Initializers

- [init(upgradeForSession:)](networkextension/nwudpsession/init(upgradeforsession:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
