#include <FileDescriptor.h>
Inheritance diagram for FileDescriptor:
Public Methods | |
FileDescriptor (ref< FileDescriptorManager > const &_fdMgr, int _fd) | |
virtual | ~FileDescriptor () |
bool | isOpen () const |
bool | inputReady () |
int | getFd () const |
ref<FileDescriptorManager> const& | getFdMgr () const |
virtual void | close () |
bool | setNonBlocking (bool on) |
void | block (bool forRead, bool forWrite) |
bool | read (int &ch) |
void | setReadCallback (ref< Callback > const &cb, Callback::Method cbm) |
void | setWriteCallback (ref< Callback > const &cb, Callback::Method cbm) |
void | clearReadCallback () |
void | clearWriteCallback () |
void | fireReadCallback () |
void | fireWriteCallback () |
int | read (char *inbuf, int len, bool complete=false) |
int | write (char const *outbuf, int len, bool complete=false) |
Protected Methods | |
virtual int | lowlevel_read (int handle, char *buf, int len) |
virtual int | lowlevel_write (int handle, char const *buf, int len) |
virtual int | lowlevel_close (int handle) |
Private Methods | |
bool | fillBuffer () |
FileDescriptor (FileDescriptor const &other) | |
FileDescriptor const& | operator= (FileDescriptor const &other) |
void | updateCallbacks () |
Private Attributes | |
ref<FileDescriptorManager> | fdMgr |
int | fd |
char | buf [1024] |
int | buflen |
int | pos |
callback_entry_t | readCallback |
callback_entry_t | writeCallback |
Works in association with a FileDescriptorManager.
Definition at line 27 of file FileDescriptor.h.
|
|
|
This constructor wraps the passed in _fd in association with the passed in _fdMgr.
|
|
The file-descriptor is close()d on destruction.
|
|
Calls select() to wait for some event on this fd only; all others are ignored. %%% (NOTE: should probably be protected rather than public; don't %%% call it unless you're sure you know what you're doing - and %%% let tonyg@kcbbs.gen.nz know if you *do* find a legitimate use %%% for it!) |
|
Clear our read-available callback - we are no longer interested in those events.
|
|
Clear our write-available callback - we are no longer interested in those events.
|
|
Closes this fd.
Reimplemented in SocketDescriptor. |
|
Fill buffer with at least one byte. Returns true if okay, false if would block.
Referenced by inputReady(), and read(). |
|
Calls the read-callback; does not clear the callback.
|
|
Calls the write-callback; does not clear the callback.
|
|
Access the file descriptor wrapped by this.
Definition at line 132 of file FileDescriptor.h. |
|
Access our controlling fdMgr.
|
|
true -> some bytes are available for read *now*.
Definition at line 127 of file FileDescriptor.h. |
|
true -> this fd is open.
Definition at line 124 of file FileDescriptor.h. Referenced by inputReady(). |
|
|
|
for sockets on Linux, where you can use send(... MSG_NOSIGNAL) etc., and for sockets on Win32 where you have to use recv and send instead of read and write. Default (superclass) behaviour is to use write and read. Reimplemented in SocketDescriptor. |
|
Reimplemented in SocketDescriptor. |
|
|
|
Read a single byte.
Definition at line 175 of file FileDescriptor.h. |
|
These process as many bytes as possible without blocking, and return the number of bytes processed, unless 'complete' is set, in which case they keep working until exactly len bytes have been processed or an exception is met.
|
|
true -> success.
|
|
Installs a callback for read-available events.
|
|
Installs a callback for write-available events.
|
|
Updates the fd_set objects in our FileDescriptorManager depending on whether we are interested in read-available, write-available, or both conditions.
|
|
Referenced by ReadCallback::sendToAll(). |
|
Input buffer (output is unbuffered).
Definition at line 74 of file FileDescriptor.h. |
|
Number of bytes in the buffer.
Definition at line 75 of file FileDescriptor.h. |
|
Unix fd we are wrapping.
Definition at line 73 of file FileDescriptor.h. |
|
The FileDescriptorManager that manages this.
Definition at line 72 of file FileDescriptor.h. |
|
Index of next byte to return.
Definition at line 76 of file FileDescriptor.h. |
|
Callback for read-available.
Definition at line 89 of file FileDescriptor.h. |
|
Callback for write-available.
Definition at line 90 of file FileDescriptor.h. |