---
title: kCFSocketCloseOnInvalidate
framework: corefoundation
role: symbol
role_heading: Global Variable
path: corefoundation/kcfsocketcloseoninvalidate
---

# kCFSocketCloseOnInvalidate

When enabled using 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.

## Declaration

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

## See Also

### Constants

- [kCFSocketAutomaticallyReenableReadCallBack](corefoundation/kcfsocketautomaticallyreenablereadcallback.md)
- [kCFSocketAutomaticallyReenableAcceptCallBack](corefoundation/kcfsocketautomaticallyreenableacceptcallback.md)
- [kCFSocketAutomaticallyReenableDataCallBack](corefoundation/kcfsocketautomaticallyreenabledatacallback.md)
- [kCFSocketAutomaticallyReenableWriteCallBack](corefoundation/kcfsocketautomaticallyreenablewritecallback.md)
- [kCFSocketLeaveErrors](corefoundation/kcfsocketleaveerrors.md)
