Contents

URLSessionStreamTask

A URL session task that is stream-based.

Declaration

class URLSessionStreamTask

Overview

URLSessionStreamTask is a concrete subclass of URLSessionTask. Many of the methods in the URLSessionStreamTask class are documented in URLSessionTask.

The URLSessionStreamTask class provides an interface a TCP/IP connection created via URLSession. Tasks may be created from an URLSession using the streamTask(withHostName:port:) and streamTask(with:) methods. They may also be created as a result of an URLSessionDataTask being upgraded via the HTTP Upgrade: response header and appropriate use of the httpShouldUsePipelining option of URLSessionConfiguration.

A 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 InputStream and OutputStream objects from an URLSessionStreamTask object by calling the captureStreams() method.

Topics

Reading and writing data

Capturing streams

Closing read and write sockets

Starting and stopping secure connections

Initializers

Type Methods

See Also

Adding stream tasks to a session