File Descriptor Programming Interface
3-8
Note: The error code returned via fdError() is stored in the file descriptor ses-
sion associated with a task. If a task calls a file or socket function before it
opens a file descriptor session, an error condition results. Obviously however,
no error code can be stored for retrieval by fdError() since the file descriptor
session doesn’t exist to hold it.
Terminate a Previous Call to fdSelect()
fdSelectAbort
Syntax
void fdSelectAbort( HANDLE hTask );
Parameter(s)
hTask
Handle to the task thread which is blocked in fdSelect()
Return Value
nothing
Description
This function aborts a previous call to fdSelect() on another thread by simulat-
ing a timeout condition (even when no timeout was originally specified). It can
be used to wake a thread using an alternate method than socket or pipe activi-
ty. It is particularly useful in callback functions where the handle to the task
thread to “wake” is known, but nothing it known about the current thread.
The return value from the fdSelect() called on the target thread is still valid
(most likely an empty descriptor set).
Convert a File Descriptor Index to a File Handle
fdGetFileHandle
Syntax
HANDLE fdGetFileHandle( int fd );
Parameter(s)
fd
File descriptor to convert
Return Value
Non-zero handle on success or NULL on error. When an error occurs, the error
type can be obtained by calling fdError().
Description
Although file descriptors are nice for functions like fdSelect(), they have a dis-
advantage in that they are not global across tasks. However, a file descriptor
can be converted to a file handle, which is global, and can be passed to another
task.
This function converts a file descriptor to a file handle. Note that after this call,
the file descriptor becomes invalid and can not be used. The handle can be
converted back to a file descriptor by calling the FileHandleGetFd() function.
Transfer File Descriptor from One Task to Another
fdTransfer
Syntax
int fdTransfer( HANDLE hSrcTask, int fdsrc, HANDLE hDstTask, int *pfddst
);
Parameter(s)
hSrcTask
Handle of task which currently owns the file descriptor
fdsrc
File descriptor to transfer