Help - Search - Members - Calendar
Full Version: Infinite lop + recv() + select()
1Emulation.Com > Official Emulator Forums > DSWifi
vha
How can I interrupt waiting for data in recv() function? I must wait until function recive data from server to proceed.

CODE
while (1)
    {
    
readbytes = recv(gniazdo, (char*)&glowa, sizeof(glowa), 0 );
  

            if (Stylus.X<19 && Stylus.Y>172)
        {
            if(keybord<=0)
                {if(keybord==-1)PA_InitKeyboard(2);PA_KeyboardIn(20, 95); keybord=1;}
            else
                {PA_KeyboardOut();keybord=0;}
                Stylus.X=0; Stylus.Y=0;
                
        }            
.
.
.
}

If i dont get data then i can't read stylus position.

I solve this problem on my PC:
CODE
struct timeval tv = {0,0};
    while(1)
    {            
                fd_set fs = {1,gniazdo};
           if (select(0, &fs,NULL,NULL,&tv) == 1)
                {    
                  
    readbytes = recv(gniazdo, (char*)&glowa, sizeof(glowa), 0);
            if (...)
        {
            ...
                
        }            
.
.
.
}

But this method don’t seam to work on DS dry.gif
what is wrong with my code? how can I fix it?

sorry for my poor Englis
Weirdy
Using select() and recv() would mean that the DS would have to be POSIX compatible, no? Or at least mean that there are libraries available that make it compatible with POSIX.
vha
QUOTE (Weirdy @ Nov 29 2007, 12:15 AM) *
Using select() and recv() would mean that the DS would have to be POSIX compatible, no? Or at least mean that there are libraries available that make it compatible with POSIX.

you want to say that i can't use select() on DS?
than why this guy is using it?:
http://www.1emulation.com/forums/index.php?showtopic=22833

as you can see code is very similar
sgstair
select() is supported in the dswifi lib - you just can't setup the fd_set like that.
Another alternative would be to use nonblocking sockets (research ioctl() and FIONBIO)

Good luck smile.gif
vha
QUOTE (sgstair @ Nov 29 2007, 12:58 AM) *
select() is supported in the dswifi lib - you just can't setup the fd_set like that.
Another alternative would be to use nonblocking sockets (research ioctl() and FIONBIO)

Good luck smile.gif

god this is so simple

thx m8
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.