Instance Method

streamTask(with:)

Creates a task that establishes a bidirectional TCP/IP connection using a specified network service.

Declaration

func streamTask(with service: NetService) -> URLSessionStreamTask

Parameters

service

An NetService object used to determine the endpoint of the TCP/IP connection. This network service is resolved before any data is read or written to the resulting stream task.

Return Value

The new session stream task.

Discussion

After you create the task, you must start it by calling its resume() method.

See Also

Adding Stream Tasks to a Session

func streamTask(withHostName: String, port: Int)

Creates a task that establishes a bidirectional TCP/IP connection to a specified hostname and port.

class URLSessionStreamTask

A URL session task that is stream-based.

protocol URLSessionStreamDelegate

The NSURLSessionStreamDelegate protocol defines delegate methods that you should implement when using URLSession stream tasks. In addition to these methods, be sure to implement the methods in the URLSessionTaskDelegate and URLSessionDelegate protocols to handle events common to all task types and session-level events, respectively.