Page 2 of 2

Re: Dswifi works but fails after 7 attempts.

Posted: Sun Feb 05, 2012 8:56 pm
by ashairey
Sorry for the delay. I had a very rough week at the office. :-(


I've looked into your suggestions.
- forceclosesocket();
According me that one doesn't exits. :wink:

- shutdown(my_socket, SHUT_RD)
- shutdown(my_socket, SHUT_WR)
- shutdown(my_socket, SHUT_RDWR)
None worked for me.

I started working on a solution to reuse the connection and i think i got i working. I can make dozens requests that are all accepted. I made a connection and let it sit for 45 minutes and after that time i succesfully send in another request. I now have to make sure that the the server side connection is release when the DS is shutdown but i will figure out something for that. I've got some ideas already.

This is naturally just a workaround in my case to the fact that the socket isn't closed/release and hopefully will be solved in a future release.

Re: Dswifi works but fails after 7 attempts.

Posted: Mon Feb 06, 2012 12:39 pm
by elhobbs
forceclosesocket does exist but the definition may not be standard. So you would need to build your own declaration. You can see it here in the dswifi svn at line 130 http://devkitpro.svn.sourceforge.net/vi ... threv=4748. Your idea is probably better as this leaves the server connection open.

Re: Dswifi works but fails after 7 attempts.

Posted: Tue Feb 21, 2012 2:41 pm
by WinterMute
Right now a shutdown socket isn't actually released for quite some time to allow buffered data to be transmitted. This is something we added to prevent a situation where delays had to be added manually before shutting down the socket. Unfortunately this means that the DS will run out of sockets quite quickly if you're attempting to implement a web or ftp server with the current library. For now the best workaround is to keep sockets open while you're using them.

We hope to fix this situation but, as usual, time is in short supply.

Re: Dswifi works but fails after 7 attempts.

Posted: Thu Sep 06, 2012 1:48 pm
by eglomer
ashairey, how do you force the server to close the connection?

I have the same problem as you. I'm getting info from a PHP web and saving it like this:

Code: Select all

while(!EGL_LookForTripleChar(data, 'ö') ){ // Exit when I get my own EndOfData, ööö
	memset(request_text,0,sizeof(request_text));
        recvd_len = recv(my_socket, request_text, EGL_MAX_BUF, 0);
		
	if ( recvd_len > 0 ){
		request_text[recvd_len] = '\0';
		strcat(data, request_text);
    	}
	else
		break;
}
And then, I close the socket with:

Code: Select all

shutdown(my_socket, SHUT_RDWR);
closesocket(my_socket);
But after 7 connections I got a socket creation error.

I've tried to wait until revc return 0 and it works, but it is VERY slow:

Code: Select all

while(1){
        memset(request_text,0,sizeof(request_text));
        recvd_len = recv(my_socket, request_text, EGL_MAX_BUF, 0);
		
	if ( recvd_len > 0 ){ // Todo bien
		request_text[recvd_len] = '\0';
		strcat(data, request_text);
    	}
	else
		break;
}
Could you help me?

Thanks. ^^