---
title: cancel()
framework: networkextension
role: symbol
role_heading: Instance Method
path: networkextension/nwudpsession/cancel()
---

# cancel()

Cancel the session.

## Declaration

```swift
func cancel()
```

## Discussion

Discussion Move into the NWUDPSessionStateCancelled state. The connection will be terminated, and all handlers will be cancelled.
