A URL session task that is stream-based.
- iOS 9.0+
- macOS 10.11+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
URLSessionStreamTask is a concrete subclass of
URLSessionTask. Many of the methods in the
URLSessionStreamTask class are documented in
URLSessionStreamTask class provides an interface a TCP/IP connection created via
URLSession. Tasks may be created from an
URLSession using the
streamTask(with:) methods. They may also created as a result of an
URLSessionDataTask being upgraded via the HTTP
Upgrade: response header and appropriate use of the
httpShouldUsePipelining option of
URLSessionStreamTask object performs asynchronous reads and writes, which are enqueued and executed serially, calling a handler upon completion being on the session delegate queue. If the task is canceled, all enqueued reads and writes will call their completion handlers with an appropriate error.
When working with APIs that accept
Stream objects, you can create
OutputStream objects from an
URLSessionStreamTask object by calling the
Closing Read and Write Sockets
Completes any enqueued reads and writes, and then closes the read side of the underlying socket.
Completes any enqueued reads and writes, and then closes the write side of the underlying socket.
Starting and Stopping Secure Connections
Adding Stream Tasks to a Session
A protocol that defines methods that URL session instances call on their delegates to handle task-level events specific to stream tasks.