delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/03/19/16:49:51

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <7909C3E22B10FA4DB1BD49A747D54FFD0EC3DA@DYN-EXCH-001.dynamicsoft.com>
From: Sean Tang <STang AT dynamicsoft DOT com>
To: "'cygwin AT cygwin DOT com'" <cygwin AT cygwin DOT com>
Subject: strange bug : select() always generate 10022 error
Date: Wed, 19 Mar 2003 15:33:24 -0500
MIME-Version: 1.0

In the folowing code :
If I include <stdio.h> before <windows.h> and <winsock2.h>, select() always
generate 10022 error.
If I include <stdio.h> after <windows.h> and <winsock2.h>, select() works
OK.


#include <stdio.h>

#include <windows.h>
#define USE_SYS_TYPES_FD_SET
#include <winsock2.h>

int main(int argc, char *argv[]) {

WORD wVersionRequested;
WSADATA wsaData;
int err;
 
wVersionRequested = MAKEWORD( 2, 2 );
 
err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 ) {
	printf("we could not find a usable WinSock DLL\n");
    return -1;
}
 
if ( LOBYTE( wsaData.wVersion ) != 2 || HIBYTE( wsaData.wVersion ) != 2 ) {
	printf("we could not find a usable WinSock DLL\n");
	WSACleanup( );
    return -1; 
}

	fd_set fds;
	
	int s= socket(AF_INET, SOCK_STREAM, 0);

	FD_ZERO(&fds);
	FD_SET((unsigned)s, &fds);

		if( select(s+1, &fds, NULL, NULL, 0) == -1 ) {
			printf("socket error : %d\n", WSAGetLastError());
			return -1;
        }

return 0;
}


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019