---
title: NWConnection
framework: network
role: symbol
role_heading: Class
path: network/nwconnection
---

# NWConnection

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

## Declaration

```swift
final class NWConnection
```

## Mentioned in

Inspecting app activity data

## Topics

### Creating Connections

- [init(host:port:using:)](network/nwconnection/init(host:port:using:).md)
- [init(to:using:)](network/nwconnection/init(to:using:).md)
- [start(queue:)](network/nwconnection/start(queue:).md)
- [restart()](network/nwconnection/restart().md)

### Handling State Updates

- [state](network/nwconnection/state-swift.property.md)
- [NWConnection.State](network/nwconnection/state-swift.enum.md)
- [stateUpdateHandler](network/nwconnection/stateupdatehandler.md)

### Sending and Receiving Data

- [send(content:contentContext:isComplete:completion:)](network/nwconnection/send(content:contentcontext:iscomplete:completion:)-5ecuz.md)
- [send(content:contentContext:isComplete:completion:)](network/nwconnection/send(content:contentcontext:iscomplete:completion:)-3mfmt.md)
- [NWConnection.SendCompletion](network/nwconnection/sendcompletion.md)
- [receive(minimumIncompleteLength:maximumLength:completion:)](network/nwconnection/receive(minimumincompletelength:maximumlength:completion:).md)
- [receiveMessage(completion:)](network/nwconnection/receivemessage(completion:).md)
- [batch(_:)](network/nwconnection/batch(_:).md)
- [NWConnection.ContentContext](network/nwconnection/contentcontext.md)
- [maximumDatagramSize](network/nwconnection/maximumdatagramsize.md)

### Canceling Connections

- [cancel()](network/nwconnection/cancel().md)
- [forceCancel()](network/nwconnection/forcecancel().md)
- [cancelCurrentEndpoint()](network/nwconnection/cancelcurrentendpoint().md)

### Handling Path Updates

- [currentPath](network/nwconnection/currentpath.md)
- [pathUpdateHandler](network/nwconnection/pathupdatehandler.md)
- [viabilityUpdateHandler](network/nwconnection/viabilityupdatehandler.md)
- [betterPathUpdateHandler](network/nwconnection/betterpathupdatehandler.md)

### Collecting Connection Metrics

- [Collecting Network Connection Metrics](network/collecting-network-connection-metrics.md)
- [requestEstablishmentReport(queue:completion:)](network/nwconnection/requestestablishmentreport(queue:completion:).md)
- [NWConnection.EstablishmentReport](network/nwconnection/establishmentreport.md)
- [startDataTransferReport()](network/nwconnection/startdatatransferreport().md)
- [NWConnection.PendingDataTransferReport](network/nwconnection/pendingdatatransferreport.md)
- [NWConnection.DataTransferReport](network/nwconnection/datatransferreport.md)

### Inspecting Connections

- [metadata(definition:)](network/nwconnection/metadata(definition:).md)
- [NWProtocolMetadata](network/nwprotocolmetadata.md)
- [endpoint](network/nwconnection/endpoint.md)
- [parameters](network/nwconnection/parameters.md)
- [queue](network/nwconnection/queue.md)

### Initializers

- [init(from:to:using:)](network/nwconnection/init(from:to:using:).md)
- [init(message:)](network/nwconnection/init(message:).md)

### Instance Methods

- [receiveDiscontiguous(minimumIncompleteLength:maximumLength:completion:)](network/nwconnection/receivediscontiguous(minimumincompletelength:maximumlength:completion:).md)
- [receiveMessageDiscontiguous(completion:)](network/nwconnection/receivemessagediscontiguous(completion:).md)

## Relationships

### Conforms To

- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Connections and Listeners

- [NWListener](network/nwlistener.md)
- [NWBrowser](network/nwbrowser.md)
- [NWConnectionGroup](network/nwconnectiongroup.md)
- [NWEthernetChannel](network/nwethernetchannel.md)
