Instance Method


Asynchronously writes the specified data to the stream, and calls a handler upon completion.


- (void)writeData:(NSData *)data timeout:(NSTimeInterval)timeout completionHandler:(void (^)(NSError *error))completionHandler;



The data to be written.


A timeout for writing bytes. If the write is not completed within the specified interval, the write is canceled and the completionHandler is called with an error. Pass 0 to prevent a write from timing out.


The completion handler to call when all bytes are written, or an error occurs. This handler is executed on the delegate queue.

This completion handler takes the following parameter:


An error object that indicates why the write failed, or nil if the write was successful.


There is no guarantee that the remote side of the stream has received all of the written bytes at the time that completionHandler is called, only that all of the data has been written to the kernel.

See Also

Reading and Writing Data

- readDataOfMinLength:maxLength:timeout:completionHandler:

Asynchronously reads a number of bytes from the stream, and calls a handler upon completion.