Homebrew DevkitPro DSWifi Connection Help!

madeinair

Well-Known Member
OP
Newcomer
Joined
Jul 16, 2011
Messages
50
Trophies
0
XP
81
Country
If anyone with homebrew knowledge could please help me out.
I'm trying to developed client/server application where the client is the DS and server is the PC, I've tried using the HTTPGET example code in the devkitpro examples, I'm able to connect to other HTTP servers, but when I try to connect to mine it always fails, fails at the line:

connect( my_socket,(struct sockaddr *)&sain, sizeof(sain) );

I've disabled firewall on port 80, I'm able to access the HTTP page through firefox by typing my IP address, but when I try to connect with the DS it doesn't accept (I've tried this in both Desmume and actual DS hardware).

The code before the connect is this:

-------------------------------------------------------------------------
struct hostent * myhost = gethostbyname( url );
iprintf("Found IP Address!\n");

// Create a TCP socket
int my_socket;
my_socket = socket( AF_INET, SOCK_STREAM, 0 );
iprintf("Created Socket!\n");

// Tell the socket to connect to the IP address we found, on port 80 (HTTP)
struct sockaddr_in sain;
sain.sin_family = AF_INET;
sain.sin_port = htons(80);
sain.sin_addr.s_addr= *( (unsigned long *)(myhost->h_addr_list[0]) );
-------------------------------------------------------------------------

I'd greatly appreciate any help ! :)
 

ipwndeveloper

Well-Known Member
Member
Joined
Jun 3, 2013
Messages
276
Trophies
0
Age
34
Location
San Fransisco, CA
Website
gb4iphone.x10.mx
XP
179
Country
United States
Did you include the libraries(in addition to the usual nds.h)?
Code:
#include <dswifi9.h>
#include <netdb.h>
#include <string.h>
#include <netinet/in.h>
#include <sys/socket.h>

Also don't forget to via the WFC Data if you do not plan to create your own lib to connect. The code below checks to see if it can connect to http://google.com
Code:
int main(void) {
    consoleDemoInit();
    ifprint("Connecting...\n");
    if(Wifi_InitDefault(WFC_CONNECT)) {
      ifprintf("Yo, You best check your wifi settings, It failed to connect bro");
} else {
  ifprintf("It actually Worked! Connected.\n\n");
getHttp("http://google.com")
 
      while(1) {
          swiWaitForVBlank();
    }
    return 0;
}

Good Luck!
 

madeinair

Well-Known Member
OP
Newcomer
Joined
Jul 16, 2011
Messages
50
Trophies
0
XP
81
Country
Thanks for the suggestion!
The example code HTTPGET already contains the checks:
----------------------------------------------------------------------------------
if(!Wifi_InitDefault(WFC_CONNECT)) {
iprintf("Failed to connect!");
} else {
iprintf("Connected\n\n");
getHttp("192.168.1.5");
}

while(1) {
swiWaitForVBlank();
}
----------------------------------------------------------------------------------
And all the libraries are added.
When I try to connect to Google or any other web server, the connection works absolutely fine !!
The problem is when I try to connect to my own web server (192.168.1.5), typing 192.168.1.5 in firefox shows the webpage but accessing it through the HTTPGET ds homebrew example doesn't work.
I also know that having the IP address as a parameter in getHttp works, tried it with the IP address of GBATemp and it got past the connection stage.
 

madeinair

Well-Known Member
OP
Newcomer
Joined
Jul 16, 2011
Messages
50
Trophies
0
XP
81
Country
I've already tried that T_T.
I've tried ur suggestion, adding ":80", trying https, all possible combinations but same problem.
I'm trying to make a homebrew for sharing files from DS to PC :), I've programmed in C before (even sockets) but have no idea why I can't get past the connection stage.
On the server side, i'm also running Accept but it's not even reaching it.
 

ipwndeveloper

Well-Known Member
Member
Joined
Jun 3, 2013
Messages
276
Trophies
0
Age
34
Location
San Fransisco, CA
Website
gb4iphone.x10.mx
XP
179
Country
United States
Wow, that is strange, perhaps its an error with the DS WiFi Stack connecting to intranet ip adresses(although I recall it working in the past), I havent been able to compile work on any DS Wireless projects in a while, due to having a WPA2 AES router and more importantly the DSWifiLib will not compile on my OS for some reason, I have yet to discover. I mainly the program work in emulation and other math/decoder projects. Wintermute (the guy who developed Devkit ARM) on their fourms. I wish I could help more but my experience with the using the DS wifi abilities is limited, If I think of something I'll be back. Also if you fix your whatever the issue is, do PM me, as I am in need of a good wifi enabled file transfer as my acekards spring is about to give out!
 

madeinair

Well-Known Member
OP
Newcomer
Joined
Jul 16, 2011
Messages
50
Trophies
0
XP
81
Country
Yep, i've already edited the request_text variable, the value now is:
----------------------------------------------------------------------------------
GET / HTTP/1.1
Host: 192.168.1.5
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:23.0) Gecko/20100101 Firefox/23.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Cache-Control: max-age=0
----------------------------------------------------------------------------------
Thanks for the suggestion!
 

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,030
Country
United States
are your ds and your pc connecting to the same access point? some APs use different networks with different ssids for 5 GHz vs 2.4 GHz. and you can have rules about wired device being accessible by wireless. use a packet sniffer (netmon works well in windows) and see if the ds packets are visible to your pc.
 

madeinair

Well-Known Member
OP
Newcomer
Joined
Jul 16, 2011
Messages
50
Trophies
0
XP
81
Country
I've solved the problem !!!
The issue was port 80 only allowed secure http connections, the android device connected to my IP with https, whilst the ds tried to connect with http only and got rejected, to solve the problem I allowed port 80 to accept any http connection (secure or not) and now it's working great!
Thanks guys :D
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    K3Nv2 @ K3Nv2: https://youtu.be/MddR6PTmGKg?si=mU2EO5hoE7XXSbSr