---
title: state
framework: networkextension
role: symbol
role_heading: Instance Property
path: networkextension/nwtcpconnection/state
---

# state

The status of the connection.

## Declaration

```swift
var state: NWTCPConnectionState { get }
```

## Discussion

Discussion Use Key-Value Observing (KVO) to monitor the state. Many methods, such as reading and writing on the connection, are only valid when the state is NWTCPConnectionStateConnected. For information about KVO, see Key-Value Observing Programming Guide.

## See Also

### Monitoring the connection status

- [NWTCPConnectionState](networkextension/nwtcpconnectionstate.md)
- [isViable](networkextension/nwtcpconnection/isviable.md)
- [error](networkextension/nwtcpconnection/error.md)
