More documentation.
5 // Created by Jens Alfke on 5/10/08.
6 // Copyright 2008 Jens Alfke. All rights reserved.
9 #import <Foundation/Foundation.h>
10 @class TCPConnection, TCPWriter;
13 /** Abstract superclass for data streams, used by TCPConnection. */
14 @interface TCPStream : NSObject
21 - (id) initWithConnection: (TCPConnection*)conn stream: (NSStream*)stream;
23 /** The connection's security level as reported by the underlying CFStream. */
24 @property (readonly) NSString *securityLevel;
26 /** The SSL property dictionary for the CFStream. */
27 @property (copy) NSDictionary* SSLProperties;
29 /** The SSL certificate(s) of the peer, if any. */
30 @property (readonly) NSArray *peerSSLCerts;
32 /** Opens the stream. */
35 /** Disconnects abruptly. */
38 /** Closes the stream politely, waiting until there's no data pending. */
41 /** Is the stream open? */
42 @property (readonly) BOOL isOpen;
44 /** Does the stream have pending data to read or write, that prevents it from closing? */
45 @property (readonly) BOOL isBusy;
47 /** Generic accessor for CFStream/NSStream properties. */
48 - (id) propertyForKey: (CFStringRef)cfStreamProperty;
50 /** Generic accessor for CFStream/NSStream properties. */
51 - (void) setProperty: (id)value forKey: (CFStringRef)cfStreamProperty;
56 /** Input stream for a TCPConnection. */
57 @interface TCPReader : TCPStream
59 /** The connection's TCPWriter. */
60 @property (readonly) TCPWriter *writer;
62 /** Reads bytes from the stream, like the corresponding method of NSInputStream.
63 The number of bytes actually read is returned, or zero if no data is available.
64 If an error occurs, it will call its -_gotError method, and return a negative number. */
65 - (NSInteger) read: (void*)dst maxLength: (NSUInteger)maxLength;
71 @interface TCPStream (Protected)
72 /** Called when the stream opens. */
75 /** Called when the stream has bytes available to read. */
78 /** Called when the stream has space available in its output buffer to write to. */
81 /** Called when the underlying stream closes due to the socket closing. */
84 /** Call this if a read/write call returns -1 to report an error;
85 it will look up the error from the NSStream and call gotError: with it.
86 This method always returns NO, so you can "return [self _gotError]". */
89 /** Signals a fatal error to the TCPConnection.
90 This method always returns NO, so you can "return [self _gotError: e]". */
91 - (BOOL) _gotError: (NSError*)error;