select behavior different with wine

Phil Lodwick Phil.Lodwick at EFI.COM
Wed Feb 1 16:14:22 CST 2006


I ran across a problem that the following code demonstrates.  I believe it is
due to the different definition of select on Windows vs Linux.  Before I
start to think about how to fix this in Wine, I was wondering if anybody has
already thought about the problem.

#include "stdafx.h"
#include <winsock2.h>

int _tmain(int argc, _TCHAR* argv[])
  SOCKET fd;
  WORD wVersionRequested;
  WSADATA wsaData;

  wVersionRequested = MAKEWORD( 2, 2 );
  WSAStartup(wVersionRequested, &wsaData);
  fd = socket(AF_INET, SOCK_STREAM, 0);
  if (fd != INVALID_SOCKET)
    fd_set readfds;
    struct timeval select_timeout ;

    FD_SET(fd, &readfds) ;
    select_timeout.tv_sec=2 ;
    select_timeout.tv_usec=0 ;

    if (select((int) fd+1, &readfds, NULL, NULL, 
      &select_timeout) != SOCKET_ERROR)
      if(FD_ISSET(fd, &readfds))
        printf("THIS IS WINE\n");
        printf("THIS IS WINDOWS\n");
      else printf("got a socket error\n");

  return 0;

More information about the wine-devel mailing list