delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/03/19/20:46:57

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
Date: Wed, 19 Mar 2003 20:46:39 -0500
From: Christopher Faylor <cgf-ycgiwn AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: strange bug : select() always generate 10022 error
Message-ID: <20030320014639.GH32580@redhat.com>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <7909C3E22B10FA4DB1BD49A747D54FFD0EC3DA AT DYN-EXCH-001 DOT dynamicsoft DOT com>
Mime-Version: 1.0
In-Reply-To: <7909C3E22B10FA4DB1BD49A747D54FFD0EC3DA@DYN-EXCH-001.dynamicsoft.com>
User-Agent: Mutt/1.5.1i

On Wed, Mar 19, 2003 at 03:33:24PM -0500, Sean Tang wrote:
>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.

It sounds like you're mixing cygwin's select with winsock select.

"You can't do that".

Get rid of all the winsock and windows stuff and just treat this like a
standard unix program.

cgf
TCM

>#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/

--
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