A class that can observe multiple streams at once. More...
#import <OFStreamObserver.h>
Public Member Functions | |
(id< OFStreamObserverDelegate >) | - delegate |
(void) | - setDelegate: |
(void) | - addStreamToObserveForReading: |
(void) | - addStreamToObserveForWriting: |
(void) | - removeStreamToObserveForReading: |
(void) | - removeStreamToObserveForWriting: |
(void) | - observe |
(BOOL) | - observeWithTimeout: |
Static Public Member Functions | |
(id) | + observer |
Protected Attributes | |
OFMutableArray * | readStreams |
OFMutableArray * | writeStreams |
OFMutableArray * | queue |
OFMutableArray * | queueInfo |
OFDataArray * | fds |
OFMutableDictionary * | fdToStream |
int | cancelFd [2] |
Properties | |
id< OFStreamObserverDelegate > | delegate |
A class that can observe multiple streams at once.
Note: Currently, Win32 can only observe sockets and not files!
- (void) addStreamToObserveForReading: | (OFStream*) | stream |
Adds a stream to observe for reading.
This is also used to observe a listening socket for incoming connections, which then triggers a read event for the observed stream.
It is recommended that the stream you add is set to non-blocking mode.
If there is an -[observe] call blocking, it will be canceled. The reason for this is to prevent blocking even though the new added stream is ready.
stream | The stream to observe for reading |
- (void) addStreamToObserveForWriting: | (OFStream*) | stream |
Adds a stream to observe for writing.
It is recommended that the stream you add is set to non-blocking mode.
If there is an -[observe] call blocking, it will be canceled. The reason for this is to prevent blocking even though the new added stream is ready.
stream | The stream to observe for writing |
- (id <OFStreamObserverDelegate>) delegate |
- (void) observe |
Observes all streams and blocks until an event happens on a stream.
+ (id) observer |
- (BOOL) observeWithTimeout: | (int) | timeout |
Observes all streams until an event happens on a stream or the timeout is reached.
timeout | The time to wait for an event, in milliseconds |
- (void) removeStreamToObserveForReading: | (OFStream*) | stream |
Removes a stream to observe for reading.
If there is an -[observe] call blocking, it will be canceled. The reason for this is to prevent the removed stream from still being observed.
stream | The stream to remove from observing for reading |
- (void) removeStreamToObserveForWriting: | (OFStream*) | stream |
Removes a stream to observe for writing.
If there is an -[observe] call blocking, it will be canceled. The reason for this is to prevent the removed stream from still being observed.
stream | The stream to remove from observing for writing |
- (void) setDelegate: | (id <OFStreamObserverDelegate>) | delegate |
Sets the delegate for the OFStreamObserver.
delegate | The delegate for the OFStreamObserver |