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

# NWConnection.ContentContext

An object that represents a message to send or receive, containing protocol metadata and send properties.

## Declaration

```swift
class ContentContext
```

## Overview

Overview For sending, you should use defaultMessage unless there is a reason to override some values. You can pass finalMessage to mark the final message in a connection. Once this context is used for sending, and the send is marked as complete, no more data can be sent on the connection. If you are using a protocol that expects message content, like WebSocket or a custom framer, create a custom context and set metadata using protocolMetadata.

## Topics

### Using Constant Send Contexts

- [defaultMessage](network/nwconnection/contentcontext/defaultmessage.md)
- [finalMessage](network/nwconnection/contentcontext/finalmessage.md)
- [defaultStream](network/nwconnection/contentcontext/defaultstream.md)

### Creating Custom Send Contexts

- [init(identifier:expiration:priority:isFinal:antecedent:metadata:)](network/nwconnection/contentcontext/init(identifier:expiration:priority:isfinal:antecedent:metadata:).md)
- [identifier](network/nwconnection/contentcontext/identifier.md)
- [protocolMetadata](network/nwconnection/contentcontext/protocolmetadata.md)
- [NWProtocolMetadata](network/nwprotocolmetadata.md)
- [antecedent](network/nwconnection/contentcontext/antecedent.md)
- [expirationMilliseconds](network/nwconnection/contentcontext/expirationmilliseconds.md)
- [relativePriority](network/nwconnection/contentcontext/relativepriority.md)

### Inspecting Receive Contexts

- [isFinal](network/nwconnection/contentcontext/isfinal.md)
- [protocolMetadata(definition:)](network/nwconnection/contentcontext/protocolmetadata(definition:).md)

## Relationships

### Inherited By

- [NWConnectionGroup.Message](network/nwconnectiongroup/message.md)

### Conforms To

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

## See Also

### 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)
- [maximumDatagramSize](network/nwconnection/maximumdatagramsize.md)
