Also - you cannot use select() on file handles. Only sockets.

Kind regards,
Carsten Sørensen

On Mon, Jun 16, 2008 at 17:15, Danny Backx <[EMAIL PROTECTED]> wrote:
> I believe you need to call WSAStartup before any winsock call. That's a
> difference between sockets on Unix (Linux, ..) and on Windows.
>
>        Danny
>
> On Mon, 2008-06-16 at 22:21 +0900, Lance Fetters wrote:
>> Target: Windows Mobile 6.0
>> Compiler: cegcc (both 0.51.0 and SVN (updated 2008-06-14))
>>
>> I'm having issues getting select() to work on my target; note that I
>> have yet to try testing other targets.
>>
>> When I tried to run the sample code included in the glibc man-page, I
>> found that it would segfault on the select() call. I then compiled it as
>> static and ran it remotely under gdb, and found that it was crashing at
>> newlib/libc/src/wince/msnet.c:175 (in the __MS_select):
>>
>>   return( (*select)(nfds, rfds, wfds, efds, timeout));
>>
>> The problem appears to be that __msnet_init() is never called, and so
>> the select function pointer is NULL.
>>
>> I added a call to __msnet_init() to the sample code below and tried
>> running it again; this time it didn't crash, but unfortunately it
>> returned the following error (via perror()):
>>
>>   select(): Bad file number
>>
>> Does anyone have any idea what the problem might be?
>> Is this, perhaps, an issue with WM6?
>>
>> Sample code follows:
>>
>> #include <stdio.h>
>> #include <stdlib.h>
>> #include <sys/time.h>
>> #include <sys/types.h>
>> #include <unistd.h>
>>
>> int
>> main(void)
>> {
>>    fd_set rfds;
>>    struct timeval tv;
>>    int retval;
>>
>>    /* __msnet_init(); */
>>
>>    /* Watch stdin (fd 0) to see when it has input. */
>>    FD_ZERO(&rfds);
>>    FD_SET(0, &rfds);
>>
>>    /* Wait up to five seconds. */
>>    tv.tv_sec = 5;
>>    tv.tv_usec = 0;
>>
>>    retval = select(1, &rfds, NULL, NULL, &tv);
>>
>>    /* Dont rely on the value of tv now! */
>>    if (retval == -1)
>>       perror("select()");
>>    else if (retval)
>>       printf("Data is available now.\n");
>>    /* FD_ISSET(0, &rfds) will be true. */
>>    else
>>       printf("No data within five seconds.\n");
>>
>>    exit(EXIT_SUCCESS);
>> }
>>
>>
>> Cheers,
>>
> --
> Danny Backx ; danny.backx - at - scarlet.be ; http://danny.backx.info
>
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> Cegcc-devel mailing list
> Cegcc-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/cegcc-devel
>
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Cegcc-devel mailing list
Cegcc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cegcc-devel

Reply via email to