gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Porting libxpnet - a sockets wrapper

#123407 - Lick - Tue Mar 27, 2007 11:21 pm

I just want to say I just successfully ported libxpnet's nsSocket.h and nsSocket.cpp to DS. Following will be nsHTTPConn.h and nsHTTPConn.cpp.

I'm reasonably happy, since the following code is needed to fetch a webpage:
Code:
  nsSocket *sock = new nsSocket("www.google.com", 80);
  sock->Open();
 
  char fetch[] = "GET / HTTP/1.1\r\n"
                 "Host: www.google.com\r\n"
                 "User-Agent: NintendoDS\r\n\r\n";
  int size = strlen(fetch);
  sock->Send((unsigned char*)fetch, &size);
 
  char data[2048] = {0};
  size = 2048;
  sock->Recv((unsigned char*)data, &size);
 
  sock->Close();
  iprintf(data);


When nsHTTPConn and nsFTPConn are done, I will release the port.
- Lick
_________________
http://licklick.wordpress.com

#123422 - DragonMinded - Wed Mar 28, 2007 1:10 am

What do you mean it's needed to fetch a webpage? I can fetch a page with just dswifi and it's socket stuff... could you elaborate?
_________________
Enter the mind of the dragon.

http://dragonminded.blogspot.com

Seriously guys, how hard is it to simply TRY something yourself?

#123425 - tepples - Wed Mar 28, 2007 1:56 am

As far as I can tell, this is supposed to be some wrapper around the socket stuff that makes HTTP easier.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#123462 - Lick - Wed Mar 28, 2007 10:05 am

Yes, it wraps the sockets implementation into a nice reusable class (therefore it's C++ only).
The interesting part is that libxpnet is also a HTTP and FTP wrapper. So it handles those protocols for you. I am probably going to write a very basic FTP client with it soon.
_________________
http://licklick.wordpress.com

#123484 - tepples - Wed Mar 28, 2007 2:07 pm

A very basic HTTP client that reads a URL from a config file and then loads a .nds directly from that URL would be a nice demo too.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#123489 - tyraen - Wed Mar 28, 2007 2:42 pm

Are you releasing them as a compiled library or source code? Maybe that's a stupid question.

#123687 - Lick - Fri Mar 30, 2007 7:48 am

I have decided to port libcurl instead of libxpnet. :)
_________________
http://licklick.wordpress.com

#123769 - thegamefreak0134 - Fri Mar 30, 2007 11:18 pm

Aww... Why? I rather liked the .NET implementation of stuff. A little odd yes, but it still worked out very nicely.

Um, would I have to do anything special to get c++ code to compile, or does devkitPRO just do it naturally?

Regardless, any tools I can use are greatly appreciated. Of course, I'm having a decent bit of luck currently with the PAlib implementation. If I can just convince it somehow to transfer the entire message in one go I'll be happy.

<rant>
(It likes to stop about halfway through the HTML code for a page. I currently have it looping until it recieves a message with length of zero, for lack of a better way to check for the end of a message. With my dial-up/wireless testing though, I think it tends to timeout when the connection is just being generally slow, causing my loop to exit prematurely.)
</rant>

Let me know when you make some headway. I'm working on a small bit of interface at the moment, so I don't have to recompile my code every time I want to change the message being sent or connect to another server. Any bit of help along this field is needed. ^_^

-thegamefreak0134
_________________
What if the hokey-pokey really is what it's all about?

[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]

#123772 - Lick - Fri Mar 30, 2007 11:36 pm

For your information, libxpnet hasn't got anything to do with .NET! ;) And yes, I too don't want to deal with the HTTP protocol and others, that's why I'm trying to port libcurl (even if only a little bit).

update
Quote:
<Lick> ok i give up.. way too tired and freetimeless to port libcurl
<Lick> someone else do it

_________________
http://licklick.wordpress.com