ObjFW
Public Member Functions | Static Public Member Functions | Protected Attributes | Properties
OFStreamObserver Class Reference

A class that can observe multiple streams at once. More...

#include <OFStreamObserver.h>

Inheritance diagram for OFStreamObserver:
OFObject <OFObject>

List of all members.

Public Member Functions

id< OFStreamObserverDelegatedelegate ()
void setDelegate: (id< OFStreamObserverDelegate > delegate)
void addStreamToObserveForReading: (OFStream *stream)
void addStreamToObserveForWriting: (OFStream *stream)
void removeStreamToObserveForReading: (OFStream *stream)
void removeStreamToObserveForWriting: (OFStream *stream)
void observe ()
BOOL observeWithTimeout: (int timeout)

Static Public Member Functions

id observer ()

Protected Attributes

OFMutableArrayreadStreams
OFMutableArraywriteStreams
OFMutableArrayqueue
OFMutableArrayqueueInfo
OFDataArrayfds
OFMutableDictionaryfdToStream
int cancelFd [2]

Properties

id< OFStreamObserverDelegatedelegate

Detailed Description

A class that can observe multiple streams at once.

Note: Currently, Win32 can only observe sockets and not files!


Member Function Documentation

void OFStreamObserver::addStreamToObserveForReading: ( OFStream stream) [virtual]

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.

Parameters:
streamThe stream to observe for reading
void OFStreamObserver::addStreamToObserveForWriting: ( OFStream stream) [virtual]

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.

Parameters:
streamThe stream to observe for writing
id <OFStreamObserverDelegate> OFStreamObserver::delegate ( ) [virtual]
Returns:
The delegate for the OFStreamObserver
void OFStreamObserver::observe ( ) [virtual]

Observes all streams and blocks until an event happens on a stream.

id OFStreamObserver::observer ( ) [static, virtual]
Returns:
A new, autoreleased OFStreamObserver
BOOL OFStreamObserver::observeWithTimeout: ( int  timeout) [virtual]

Observes all streams until an event happens on a stream or the timeout is reached.

Parameters:
timeoutThe time to wait for an event, in milliseconds
Returns:
A boolean whether events occurred during the timeinterval
void OFStreamObserver::removeStreamToObserveForReading: ( OFStream stream) [virtual]

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.

Parameters:
streamThe stream to remove from observing for reading
void OFStreamObserver::removeStreamToObserveForWriting: ( OFStream stream) [virtual]

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.

Parameters:
streamThe stream to remove from observing for writing
void OFStreamObserver::setDelegate: ( id <OFStreamObserverDelegate delegate) [virtual]

Sets the delegate for the OFStreamObserver.

Parameters:
delegateThe delegate for the OFStreamObserver

The documentation for this class was generated from the following files:
 All Classes Functions Variables