_NutFdToHandle()

return Win32 file handle associated with NuTCRACKER Platform file descriptor 

Function


SYNOPSIS

#include <winnutc.h>

HANDLE _NutFdToHandle(int fd);


DESCRIPTION

The _NutFdToHandle() function returns the Win32 file handle associated with the specified NuTCRACKER Platform file descriptor. This is useful when integrating NuTCRACKER Platform code with Win32 native code, as the resulting handle can be used with Win32 API functions.

The returned handle should not be closed with CloseHandle(). The underlying handle is closed by the NuTCRACKER Platform when close() is called on the file descriptor (either explicitly or when the process exits).

Be careful when sharing handles between NuTCRACKER Platform and Win32 code. When the Win32 code change settings on the underlying object (for example, calls ioctl() on a socket handle obtained from a NuTCRACKER Platform socket file descriptor), the NuTCRACKER Platform is unaware of those changes, and program behavior for that handle/file descriptor is undefined. Unless the handle and file descriptor are being shared simply for I/O operations, and not control operations, once the handle has been used in Win32 code, the corresponding file descriptor should not be used further in NuTCRACKER Platform code. This issue is especially important for sockets, because the NuTCRACKER Platform needs to manipulate the settings of WinSock sockets to ensure that socket operations are correctly interruptible.


PARAMETERS

fd 

Is the file descriptor whose corresponding handle is to be returned.


RETURN VALUES

If successful, _NutFdToHandle() returns the Win32 file handle corresponding to the specified file descriptor. On failure, it returns a value of INVALID_HANDLE_VALUE and sets errno to one of the following values:

EBADF 

The specified file descriptor is not valid.

EINTR 

A signal interrupted the call.


CONFORMANCE

PTC MKS Toolkit UNIX APIs extension.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

None.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
_NutHandleToFd()


PTC MKS Toolkit 10.5 Documentation Build 40.