Dswifi works but fails after 7 attempts.

ashairey
Posts: 10
Joined: Fri Jan 27, 2012 2:33 pm

Re: Dswifi works but fails after 7 attempts.

Post by ashairey » Sun Feb 05, 2012 8:56 pm

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.

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

Re: Dswifi works but fails after 7 attempts.

Post by elhobbs » Mon Feb 06, 2012 12:39 pm

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.

WinterMute
Site Admin
Posts: 1845
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Dswifi works but fails after 7 attempts.

Post by WinterMute » Tue Feb 21, 2012 2:41 pm

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.
Help keep devkitPro toolchains free, Donate today

Personal Blog

eglomer
Posts: 4
Joined: Thu Sep 24, 2009 3:48 pm

Re: Dswifi works but fails after 7 attempts.

Post by eglomer » Thu Sep 06, 2012 1:48 pm

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. ^^

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 13 guests