<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/kCFSocketCloseOnInvalidate",
  "metadataVersion" : "0.1.0",
  "role" : "Global Variable",
  "symbol" : {
    "kind" : "Global Variable",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@Ea@kCFSocketAutomaticallyReenableReadCallBack@kCFSocketCloseOnInvalidate"
  },
  "title" : "kCFSocketCloseOnInvalidate"
}
-->

# kCFSocketCloseOnInvalidate

When enabled using [`CFSocketSetSocketFlags(_:_:)`](/documentation/CoreFoundation/CFSocketSetSocketFlags(_:_:)), the native socket associated with a CFSocket object is closed when the CFSocket object is invalidated. When disabled, the native socket remains open. This option is enabled by default.

```
var kCFSocketCloseOnInvalidate: CFOptionFlags { get }
```

---

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)