This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: strange bug : select() always generate 10022 error


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]