File Descriptor Programming Interface
3-5
Sockets and Stream IO API
3.2
File Descriptor Programming Interface
3.2.1
Synopsis
The purpose of supporting a file system is to support the sockets API. Unfortu-
nately, the sockets API is not a complete IO API as it was originally designed
to integrate into the Unix file system. Thus, several file descriptor functions that
have become very important to the application programmer are not really
socket calls at all. The stack library supports a handful of what would normally
considered file functions so that sockets applications can be programmed in
a more traditional sense. In order that these functions will not conflict with any
other file functions in the system, their names have been altered slightly from
the standard definitions.
3.2.2
Function Overview
The stream IO object can take two forms. In the vast majority of cases, it will
be in the form of a local file descriptor. The following functions can operate on
file descriptors:
fdOpenSession()
Open file descriptor support session
fdCloseSession()
Close file descriptor support session
fdSelect()
Wait on one or more file events (same as stan-
dard select())
fdClose()
Flush stream and close file descriptor (same as
standard close())
fdError()
Return last error value (same as standard errno)
fdSelectAbort()
Terminates a previous call to fdSelect() by simu-
lating a timeout condition
fdGetFileHandle()
Convert local task file descriptor to global file
HANDLE
fdTransfer()
Transfer file descriptor from one task to another
The file descriptor can be converted to a global file handle, which can then be
passed to another task thread. The handle is usually converted back to a file
descriptor by the receiving task thread. The following functions can operate on
file handles:
FileHandleClose()
Close file HANDLE (without converting back to
file descriptor)
FileHandleGetFd()
Convert global file HANDLE to local task file
descriptor