Up

NSStream documentation

Authors

Derek Zhou (derekzhou@gmail.com)

Copyright: (C) 2006 Free Software Foundation, Inc.


Contents -

  1. Software documentation for the GSServerStream class
  2. Software documentation for the NSInputStream class
  3. Software documentation for the NSOutputStream class
  4. Software documentation for the NSStream class
  5. Software documentation for the NSObject(NSStreamDelegate) informal protocol
  6. Software documentation for the NSStream(GNUstepExtensions) category

Software documentation for the GSServerStream class

GSServerStream : NSStream

Declared in:
Foundation/NSStream.h
Availability: MacOS-X 10.4.0, Base 1.2.0

GSServerStream is a subclass of NSStream that encapsulate a "server" stream; that is a stream that binds to a socket and accepts incoming connections
Method summary

serverStreamToAddr: 

+ (id) serverStreamToAddr: (NSString*)addr;
Availability: MacOS-X 10.4.0, Base 1.2.0

Create a local (unix domain or named pipe) server stream

serverStreamToAddr: port: 

+ (id) serverStreamToAddr: (NSString*)addr port: (int)port;
Availability: MacOS-X 10.4.0, Base 1.2.0

Createe a ip (ipv6) server stream

acceptWithInputStream: outputStream: 

- (void) acceptWithInputStream: (NSInputStream**)inputStream outputStream: (NSOutputStream**)outputStream;
Availability: MacOS-X 10.4.0, Base 1.2.0

This is the method that accepts a connection and generates two streams as the server side inputStream and OutputStream. Although you still need to open them, the open will be instantanious, and no NSStreamEventOpenCompleted event will be delivered.

initToAddr: 

- (id) initToAddr: (NSString*)addr;
Availability: MacOS-X 10.4.0, Base 1.2.0

the designated initializer for a local (unix domain or named pipe) server stream

initToAddr: port: 

- (id) initToAddr: (NSString*)addr port: (int)port;
Availability: MacOS-X 10.4.0, Base 1.2.0

the designated initializer for a ip (ipv6) server stream

Software documentation for the NSInputStream class

NSInputStream : NSStream

Declared in:
Foundation/NSStream.h
Availability: MacOS-X 10.4.0, Base 1.2.0

NSInputStream is a subclass of NSStream that provides read-only stream functionality.
Method summary

inputStreamWithData: 

+ (id) inputStreamWithData: (NSData*)data;
Availability: MacOS-X 10.4.0, Base 1.2.0

Creates and returns an initialized NSInputStream object for reading from data.

inputStreamWithFileAtPath: 

+ (id) inputStreamWithFileAtPath: (NSString*)path;
Availability: MacOS-X 10.4.0, Base 1.2.0

Creates and returns an initialized NSInputStream object that reads data from the file at the specified path.

getBuffer: length: 

- (BOOL) getBuffer: (uint8_t**)buffer length: (unsigned int*)len;
Availability: MacOS-X 10.4.0, Base 1.2.0

Returns a pointer to the read buffer in buffer and, by reference, the number of bytes available in len.

hasBytesAvailable 

- (BOOL) hasBytesAvailable;
Availability: MacOS-X 10.4.0, Base 1.2.0

Returns YES if the receiver has bytes available to read. The receiver may also return YES if a read must be attempted in order to determine the availability of bytes.

initWithData: 

- (id) initWithData: (NSData*)data;
Availability: MacOS-X 10.4.0, Base 1.2.0

Returns an initialized NSInputStream object for reading from data.

initWithFileAtPath: 

- (id) initWithFileAtPath: (NSString*)path;
Availability: MacOS-X 10.4.0, Base 1.2.0

Returns an initialized NSInputStream object for reading from the file at the specified path.

read: maxLength: 

- (int) read: (uint8_t*)buffer maxLength: (unsigned int)len;
Availability: MacOS-X 10.4.0, Base 1.2.0

Reads up to len bytes into buffer, returning the actual number of bytes read.

Software documentation for the NSOutputStream class

NSOutputStream : NSStream

Declared in:
Foundation/NSStream.h
Availability: MacOS-X 10.4.0, Base 1.2.0

NSOutputStream is a subclass of NSStream that provides write-only stream functionality.
Method summary

outputStreamToBuffer: capacity: 

+ (id) outputStreamToBuffer: (uint8_t*)buffer capacity: (unsigned int)capacity;
Availability: MacOS-X 10.4.0, Base 1.2.0

Creates and returns an initialized NSOutputStream object that can write to buffer, up to a maximum of capacity bytes.

outputStreamToFileAtPath: append: 

+ (id) outputStreamToFileAtPath: (NSString*)path append: (BOOL)shouldAppend;
Availability: MacOS-X 10.4.0, Base 1.2.0

Creates and returns an initialized NSOutputStream object for writing to the file specified by path.

outputStreamToMemory 

+ (id) outputStreamToMemory;
Availability: MacOS-X 10.4.0, Base 1.2.0

Creates and returns an initialized NSOutputStream object that will write stream data to memory.

hasSpaceAvailable 

- (BOOL) hasSpaceAvailable;
Availability: MacOS-X 10.4.0, Base 1.2.0

Returns YES if the receiver can be written to, or if a write must be attempted in order to determine if space is available.

initToBuffer: capacity: 

- (id) initToBuffer: (uint8_t*)buffer capacity: (unsigned int)capacity;
Availability: MacOS-X 10.4.0, Base 1.2.0

Returns an initialized NSOutputStream object that can write to buffer, up to a maximum of capacity bytes.

initToFileAtPath: append: 

- (id) initToFileAtPath: (NSString*)path append: (BOOL)shouldAppend;
Availability: MacOS-X 10.4.0, Base 1.2.0

Returns an initialized NSOutputStream object for writing to the file specified by path.
If shouldAppend is YES, newly written data will be appended to any existing file contents.

initToMemory 

- (id) initToMemory;
Availability: MacOS-X 10.4.0, Base 1.2.0

Returns an initialized NSOutputStream object that will write to memory.

write: maxLength: 

- (int) write: (const uint8_t*)buffer maxLength: (unsigned int)len;
Availability: MacOS-X 10.4.0, Base 1.2.0

Writes the contents of buffer, up to a maximum of len bytes, to the receiver.

Software documentation for the NSStream class

NSStream : NSObject

Declared in:
Foundation/NSStream.h
Availability: MacOS-X 10.4.0, Base 1.2.0

NSStream is an abstract class for objects representing streams.
Method summary

getStreamsToHost: port: inputStream: outputStream: 

+ (void) getStreamsToHost: (NSHost*)host port: (int)port inputStream: (NSInputStream**)inputStream outputStream: (NSOutputStream**)outputStream;
Availability: MacOS-X 10.4.0, Base 1.2.0

Creates and returns by reference an NSInputStream object and NSOutputStream object for a socket connection with the specified port on host.

close 

- (void) close;
Availability: MacOS-X 10.4.0, Base 1.2.0

Closes the receiver.
Repeated calls to this method on the same stream are quietly ignored.

delegate 

- (id) delegate;
Availability: MacOS-X 10.4.0, Base 1.2.0

Returns the receiver's delegate.

open 

- (void) open;
Availability: MacOS-X 10.4.0, Base 1.2.0

Opens the receiving stream.
Upon completion of the open operation, an NSStreamEventOpenCompleted event is sent to the recevier's delegate.
Repeated calls to this method on the same stream are quietly ignored.

propertyForKey: 

- (id) propertyForKey: (NSString*)key;
Availability: MacOS-X 10.4.0, Base 1.2.0

Returns the receiver's property for the specified key.

removeFromRunLoop: forMode: 

- (void) removeFromRunLoop: (NSRunLoop*)aRunLoop forMode: (NSString*)mode;
Availability: MacOS-X 10.4.0, Base 1.2.0

Removes the receiver from the NSRunLoop specified by aRunLoop running in the mode.
Attempts to remove the receiver from a run loop or a mode in which it has not been scheduled are quietly ignored.

scheduleInRunLoop: forMode: 

- (void) scheduleInRunLoop: (NSRunLoop*)aRunLoop forMode: (NSString*)mode;
Availability: MacOS-X 10.4.0, Base 1.2.0

Schedules the receiver on aRunLoop using the specified mode.
You must not attempt to add a stream to more than one run loop, but you may call this method multiple times to add the receiver in different modes for the same run loop.

setDelegate: 

- (void) setDelegate: (id)delegate;
Availability: MacOS-X 10.4.0, Base 1.2.0

Sets the receiver's delegate.

setProperty: forKey: 

- (BOOL) setProperty: (id)property forKey: (NSString*)key;
Availability: MacOS-X 10.4.0, Base 1.2.0

Sets the value of the property specified by key to property, returns YES if the key-value pair are accepted by the receiver.

streamError 

- (NSError*) streamError;
Availability: MacOS-X 10.4.0, Base 1.2.0

Returns an NSError object representing the stream error, or nil if no error has been encountered.

streamStatus 

- (NSStreamStatus) streamStatus;
Availability: MacOS-X 10.4.0, Base 1.2.0

Returns the receiver's status.

Software documentation for the NSObject(NSStreamDelegate) informal protocol

NSObject(NSStreamDelegate)

Declared in:
Foundation/NSStream.h
Availability: MacOS-X 10.4.0, Base 1.2.0

Informal protocol for delegates of instance of the NSStream class.
Method summary

stream: handleEvent: 

- (void) stream: (NSStream*)sStream handleEvent: (NSStreamEvent)anEvent;
Availability: MacOS-X 10.4.0, Base 1.2.0

Description forthcoming.

Software documentation for the NSStream(GNUstepExtensions) category

NSStream(GNUstepExtensions)

Declared in:
Foundation/NSStream.h
Availability: MacOS-X 10.4.0, Base 1.2.0

the additional interface defined for gnustep
Method summary

getLocalStreamsToPath: inputStream: outputStream: 

+ (void) getLocalStreamsToPath: (NSString*)path inputStream: (NSInputStream**)inputStream outputStream: (NSOutputStream**)outputStream;
Availability: MacOS-X 10.4.0, Base 1.2.0

Creates and returns by reference an NSInputStream object and NSOutputStream object for a local socket or named pipe connection with the specified path. To use them you need to open them and wait on the NSStreamEventOpenCompleted event on one of them.

pipeWithInputStream: outputStream: 

+ (void) pipeWithInputStream: (NSInputStream**)inputStream outputStream: (NSOutputStream**)outputStream;
Availability: MacOS-X 10.4.0, Base 1.2.0

Creates and returns by reference an NSInputStream object and NSOutputStream object for a anonymous local socket or pipe. Although you still need to open them, the open will be instantaneous, and no NSStreamEventOpenCompleted event will be delivered.


Up