File Descriptor Programming Interface
3-10
Convert a File Handle to a File Descriptor
FileHandleGetFd
Syntax
int FileHandleGetFd( HANDLE hFile );
Parameter(s)
hFile
Handle to file to convert
Return Value
File descriptor or –1 on error. This function is not strictly part of the file descrip-
tor function set, and does not elaborate on error conditions via 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, file handles are
global and can be passed from one task to another. This function converts a
global file handle to a file descriptor that is local to the calling task. The returned
file descriptor can then be used in other file or socket calls.
This function converts a file handle to a file descriptor. Note that after this call,
the file handle should no longer be used.
3.2.5
File Descriptor Set (fd_set) Macros
Add a File Descriptor to a File Descriptor Set
FD_SET
Syntax
void FD_SET( int fd, fd_set *pFdSet );
Parameter(s)
fd
File descriptor to add
pFdSet
Pointer to fd_set data type
Return Value
Should be treated as a void function. The true return value is dependent on the
implementation of the macro.
Description
This function is used to add a file descriptor to a file descriptor set, typically
before using the set in a call to fdSelect(). Note that after declaring a fd_set
data type, it should be initialized using FD_ZERO() before attempting to set
individual file descriptors.
Remove a File Descriptor from a File Descriptor Set
FD_CLR
Syntax
void FD_CLR( int fd, fd_set *pFdSet );
Parameter(s)
fd
File descriptor to remove
pFdSet
Pointer to fd_set data type