Type Method


Creates a new dispatch source object for reading bytes from the specified file.


class func makeReadSource(fileDescriptor: Int32, queue: DispatchQueue? = nil) -> DispatchSourceRead



A file descriptor pointing to an open file or socket. The dispatch source begins reading at the file descriptor's current location.


The dispatch queue to which to execute the installed handlers.

Return Value

A dispatch source object that conforms to the DispatchSourceRead protocol.


After creating the dispatch source, use the methods of the DispatchSourceProtocol protocol to install the event handlers you need. The returned dispatch source is in the inactive state initially. When you are ready to begin processing events, call its activate() method.

As the system reads the contents of the file or socket, it calls your event handler to process the bytes.

See Also

Creating a File System Source

class func makeWriteSource(fileDescriptor: Int32, queue: DispatchQueue?) -> DispatchSourceWrite

Creates a new dispatch source object for writing data to the specified file.

protocol DispatchSourceRead

A dispatch source object for reading data from a file descriptor.

protocol DispatchSourceWrite

A dispatch source object for writing data to a file descriptor.

protocol DispatchSourceFileSystemObject

A dispatch source that monitors events associated with a file descriptor.

struct DispatchSource.FileSystemEvent

Events involving a change to a file system object.