PRB: Winsock select() Returns WSAENOTSOCK
PSS ID Number: Q110775
Article last modified on 07-27-1994

3.10

WINDOWS NT


----------------------------------------------------------------------
The information in this article applies to:

 - Microsoft Win32 Software Development Kit (SDK) for Windows NT
   version 3.1
----------------------------------------------------------------------

SYMPTOMS
========

The default packing on Microsoft x86 compilers is /Zp8. If you change the
packing on your module by specifying the /Zp option with some other number,
the select() function will return the error WSAENOTSOCK.

CAUSE
=====

The prototype for the select() function is as follows:

   int PASCAL FAR select (int, fd_set FAR *, fd_set FAR *,
      fd_set FAR *, const struct timeval FAR *)

   int nfds;
   fd_set FAR *readfds;
   fd_set FAR *writefds;
   fd_set FAR *exceptfds;
   const struct timeval FAR *timeout;

It is important that the structures of type fd_set be packed with /Zp8.

RESOLUTION
==========

If the structure packing has been changed with the /Zp option on the
compiler command line, put the following

   #pragma pack(8) {
      ...
   }
   #pragma pack()

around the definition of fd_set in the WINSOCK.H header file to eliminate
the WSAENOTSOCK error.

STATUS
======

In Windows NT 3.5, the short (the first fd_set structure element) was
changed to an int to avoid this alignment problem.

Additional reference words: 3.10
KBCategory: Prg
KBSubcategory: NtwkWinsock

=============================================================================

Copyright Microsoft Corporation 1994.
