Jump to content
  • Advertisement
Sign in to follow this  
m0ng00se

Connect to web from my code [Resolved]

This topic is 3863 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Yo VC++ 2008 Win API not MFC... I want to do a menu choice in my app that connects the user to my web site. Just wondered about what sort of C++ code I need to do that? Will I need to open a socket or something (I'm just guessing, I really have no idea but I vaguely remember having to do that when I modified Eggbot code years ago)? Can't find any sample code on the net other than IRC stuff and I'm not sure how much of that socket stuff is IRC related and how much of it I need just to check for an internet connection and then send a user to my web site. m0ng00se [Edited by - m0ng00se on March 18, 2008 3:30:07 PM]

Share this post


Link to post
Share on other sites
Advertisement
It depends on what you mean by connect to your website. If you just want to open your website in a new window using the user's default browser you can use ShellExecute().

Share this post


Link to post
Share on other sites
Yup. Open a socket to the web server's IP on port 80, then send an HTTP request, like:

GET /path/to/file/filename.ext HTTP/1.0
Host: ServerName.com
Connection: Close



Where each line ends with "\r\n", and the there's a blank line at the end of the request. If all goes well, you'll get the file you requested, after the HTTP response header (Which ends with a blank line).

Share this post


Link to post
Share on other sites
Thanx.

I just want a menu choice in the HELP menu of my game like most apps have these days so a user can go and download bugfix patches, updates, tutorials etc. Nothing fancy at all. I can do the menu stuff in my sleep but just a bit vague about the internet/web side of things. Thanx for the help, I'll try it out today.

Do I need any cleanup code afterwards to close the socket or anything or does Windows take care of all that for me? Like if they shut the web page I won't be left with an open socket or anything? Sorry if my question seems a bit dumb but I'm not used to writing any code that connects to the net.

m0ng00se

Share this post


Link to post
Share on other sites
It sounds like using ShellExecute is for you.
I am not sure if ShellExecute creates a new process, and how/when this process is closed. I suspect it works the same way the old exec* functions did and "becomes" the process it opened. If that is the case you don't have to worry about a thing. Just use it and let it fly

Share this post


Link to post
Share on other sites
Thanx that works great.

I also found the function WinInet() and all it's associated HTTP functionality but ShellExecute should do the trick just fine for what I want.

Thanx guys, your help was much appreciated.

m0ng00se

http://www/freewebs.com/m0ng00se/

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!