<!--
{
  "availability" : [
    "iOS: 5.0.0 - 13.0.0",
    "iPadOS: 5.0.0 - 13.0.0",
    "macCatalyst: 13.1.0 - 13.1.0",
    "macOS: 10.8.0 - 10.15.0"
  ],
  "documentType" : "symbol",
  "framework" : "Security",
  "identifier" : "/documentation/Security/SSLGetDatagramWriteSize(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Security"
    ],
    "preciseIdentifier" : "c:@F@SSLGetDatagramWriteSize"
  },
  "title" : "SSLGetDatagramWriteSize(_:_:)"
}
-->

# SSLGetDatagramWriteSize(_:_:)

Provides the largest packet that the OS guarantees it can send without fragmentation.

```
func SSLGetDatagramWriteSize(_ dtlsContext: SSLContext, _ bufSize: UnsafeMutablePointer<Int>) -> OSStatus
```

## Parameters

`dtlsContext`

The SSL context associated with the connection.

`bufSize`

The address of a `size_t` integer for storing the length.

## Return Value

A result code. See [Secure Transport Result Codes](/documentation/Security/secure-transport-result-codes).

## Discussion

Although any packet below this threshold size will not be fragmented by the OS when sent using [`SSLWrite(_:_:_:_:)`](/documentation/Security/SSLWrite(_:_:_:_:)), this function provides no guarantees about whether the packet will be fragmented by routers en route. This size value is equal to the maximum Datagram Record size (set by calling [`SSLSetMaxDatagramRecordSize(_:_:)`](/documentation/Security/SSLSetMaxDatagramRecordSize(_:_:))) minus the DTLS Record header size.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)