dswifi problem? {accept&close)x7 = guru meditation

Post Reply
matsuri
Posts: 2
Joined: Thu Aug 13, 2009 4:35 am

dswifi problem? {accept&close)x7 = guru meditation

Post by matsuri » Thu Aug 13, 2009 4:43 am

I'm developing some sort of server and spent some time debugging a problem where it crashes when it accepts the 7th connection.

After many experiments, I decided to write a very simple test case, because I suspected a bug in the sdk somewhere... and the test case crashes, exactly at the 7th time!

So it probably is an SDK bug (my SDK was installed 2 days ago, got latest versions of everything).

I use an EzFlash Vi on a DSi.

Test case does just the following:

Code: Select all

void tcpserv(){
        int sd, psd,addrlen;
        struct sockaddr_in name,addr;
        sd = socket (AF_INET,SOCK_STREAM,0);
        name.sin_family = AF_INET;
        name.sin_addr.s_addr = htonl(INADDR_ANY);
        name.sin_port = htons(80);
        bind(sd, (struct sockaddr *)&name, sizeof(name));
        listen(sd,1);
        addrlen=sizeof(addr);
        while(1){
                do{
                        psd = accept(sd,(struct sockaddr *)&addr, &addrlen);
                } while(!psd);
                printf("%d,",psd);
                shutdown(psd,SHUT_RDWR);
                close(psd);
        }
}
The whole source to test is available at: http://pty.yi.org/dstcplistener_clean.c
Prebuild NDS at: http://pty.yi.org/dstcplistener.nds

elhobbs
Posts: 358
Joined: Thu Jul 02, 2009 1:19 pm

Re: dswifi problem? {accept&close)x7 = guru meditation

Post by elhobbs » Thu Aug 13, 2009 1:36 pm

have you tried this with a card other than the ezflash Vi? I have the Vi and the V. I have some issues when using the Vi sometimes - on things where the V seams to work ok.

matsuri
Posts: 2
Joined: Thu Aug 13, 2009 4:35 am

Re: dswifi problem? {accept&close)x7 = guru meditation

Post by matsuri » Tue Aug 18, 2009 5:48 am

elhobbs wrote:have you tried this with a card other than the ezflash Vi? I have the Vi and the V. I have some issues when using the Vi sometimes - on things where the V seams to work ok.
I would. I don't have more cards to try with, however.

Thankfully if somebody tries the test case I wrote, if it is reproduceable (or not, that would be interesting!) can be determined quite quick.

My gut tells me everybody who tries it will experience the have the same issue, however.

Alkiera
Posts: 4
Joined: Sat Aug 15, 2009 2:39 pm

Re: dswifi problem? {accept&close)x7 = guru meditation

Post by Alkiera » Tue Aug 18, 2009 8:06 am

Downloaded your .nds to my hardware; DSLite with Datel GnM; same issue. Tho technically, it never gets to the 'close' portion of the code the 7th time, the connection stays open; had to manually close telnet that 7th time.

Alkiera

MrAndini
Posts: 21
Joined: Mon Dec 08, 2008 12:32 am

Re: dswifi problem? {accept&close)x7 = guru meditation

Post by MrAndini » Sat Sep 26, 2009 2:56 am

I have found that if you do shutdown followed immediately by close, the other end of the TCP link doesn't always see the close of the TCP connection, so it thinks the connection is still active.

In my code I put a delay of 60 frames in between shutdown and close and the other end always correctly sees the shutdown of the link.

I don't know if this is related, but may be worth you giving it a try, might help identify the problem at least.

Quirky
Posts: 19
Joined: Thu Nov 15, 2007 8:45 pm

Re: dswifi problem? {accept&close)x7 = guru meditation

Post by Quirky » Fri Jan 08, 2010 9:21 pm

Try with closesocket() instead of close().

EDIT: hmm, maybe not as that changes the semantics of the example...

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 71 guests