<!--
{
  "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/URLSessionStreamDelegate/urlSession(_:writeClosedFor:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(pl)NSURLSessionStreamDelegate(im)URLSession:writeClosedForStreamTask:"
  },
  "title" : "urlSession(_:writeClosedFor:)"
}
-->

# urlSession(_:writeClosedFor:)

Tells the delegate that the write side of the underlying socket has been closed.

```
optional func urlSession(_ session: URLSession, writeClosedFor streamTask: URLSessionStreamTask)
```

## Parameters

`session`

The session containing the stream task that closed writes.

`streamTask`

The stream task that closed writes.

## Discussion

This method may be called even if no writes are currently in progress.

---

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)