<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URLSessionStreamTask/closeRead()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSURLSessionStreamTask(im)closeRead"
  },
  "title" : "closeRead()"
}
-->

# closeRead()

Completes any enqueued reads and writes, and then closes the read side of the underlying socket.

```
func closeRead()
```

## Discussion

You may continue to write data using the [`write(_:timeout:completionHandler:)`](/documentation/Foundation/URLSessionStreamTask/write(_:timeout:completionHandler:)) method after calling this method. Any calls to [`readData(ofMinLength:maxLength:timeout:completionHandler:)`](/documentation/Foundation/URLSessionStreamTask/readData(ofMinLength:maxLength:timeout:completionHandler:)) after calling this method will result in an error.

---

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)