HOWTO: Use ReadFile() and WriteFile() on Socket Descriptors

ID: Q104536

The information in this article applies to:

SUMMARY

Socket handles for Windows NT sockets are object handles. For example, you can pass a socket handle in the appropriate state to the ReadFile(), ReadFileEx(), WriteFile(), or WriteFileEx() application programming interface (API) to receive and send data. The socket descriptor passed to the file APIs must be a connected, TCP descriptor.

NOTE: There is no way to specify send and receive out-of-band data.

To use a Windows Sockets handle, the ReadFile() and WriteFile() APIs must use asynchronous access. That is, you must specify the overlapped parameter in the call to ReadFile() and WriteFile(). This will allow you to be notified when the I/O has completed.

This functionality is based upon the implementation of Windows Sockets and may not be available to all implementations. For example, although this works in the Win32 subsystem, it is not supported under Win32s.

Additional query words:

Keywords          : kbnetwork kbAPI kbNTOS310 kbNTOS350 kbSDKPlatform kbWinsock kbGrpNet 
Issue type        : kbhowto

Last Reviewed: July 31, 1998