🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Networking without a dedicated server

Started by
7 comments, last by Blackstream 23 years, 9 months ago
Hello, I was looking into starting Network programming with Winsock, but there is this tiny little thing I was wondering about. I don''t have a dedicated server, dedicated solely to running computer games, with its own URL and stuff like that. All I have to develop stuff on is a little computer that hooks up to a service provider, which means my IP changes every time I connect to the internet. So, if I wanted to make a Networking game, is there a way I can have people connecting to each other and stuff without forcing people to figure out their IP number and ICQ it to their friends, or whatever? -Blackstream "See you later, I'm going to go grab a few Bytes. I'm so thirsty, I could drink a whole data stream."
-Blackstream Will you, won't you, will you, won't you, won't you take my virus?-The Mad HackerBlackstream's Webpage
Advertisement
you''d use a master server method.
But that would require a fixed IP...unless you could point to a DNS name and use a service that provide dynamic IP with fixed DNS name (I think it''s called dyndns.org ?)

For the idea of master server :
basically, when a player connects, the game will contact the master server, and get a list of connected servers ... after that just select the one you want to use, and play.
(that''s way most FPS seem to do it now).
But you need a fixed adress to refer too, anyway ...
Or you are on a local network, and in this case that''s another story.

youpla :-P
-----------------------------Sancte Isidore ora pro nobis !
Why not try to store the active servers on a website wit the help of cgi. Every time when a server comes online it would post it''s ip to the script. Then clients would query the script for servers.
Hey, that''s a good idea, Nano! And I could use some free website that allowed CGI scripting or something. Now to learn Winsock...

Thank you ahw and nano.

-Blackstream

"See you later, I'm going to go grab a few Bytes. I'm so thirsty, I could drink a whole data stream."
-Blackstream Will you, won't you, will you, won't you, won't you take my virus?-The Mad HackerBlackstream's Webpage
Re: dedicated website

I was thinking of doing something similar. I've been looking for a (preferably free) webspace provider for some time that allows me to write my own server-side CGI scripts, but in the meantime I've been toying with a more kludged method:

There's plenty of free webpage counter services available, at least one of which (http://www.escati.com/) can also list the IP addresses of the last 30 people who have visited your site. To best use this sort of service, people wouldn't actually visit the website in their browser; the game could emulate a browser and retrieve the list of IP addresses itself.

My question is: how do I read webpages (preferably with a Visual C++ or DirectX function call)?

Dave

Edited by - Heraldin on September 16, 2000 11:26:11 AM
I''m sorry to disappoint you, but there''s not a function call in the Win32 API or DX that will read a webpage for you. You''ll have to write a HTTP client (check out faqs.org for the HTTP RFC). You will then have to parse the HTML to get the correct info you want from it.
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
BUT.. there are libraries you can use that have those functions... Besides, it''s not that hard to parse the http message from the server.. if you do a very simple parser..
http is extremely simple. Make a simple winsock app to listen on port 80 and connect to 127.0.0.1 through IE and you''ll see what IE sends out to your server. I wrote a server for http://gdtalker.cjb.net (by the time you read this, the page might be down.)

---------------------------
"Don't die for your country, make some other dumb bastard die for his" -General George S. Patton
I''ve been reading MSDN, and come up with the following:

Using Visual C++ with the Platform SDK, include the wininet.h head file and link to the wininet.lib library.

Use InternetAttemptConnect(0) to get an internet connection (evoking the dialup dialog box if not already connected). This returns ERROR_SUCCESS if successful. Otherwise, consider whether to allow working offline.

Now, use
hNet = InternetOpen("MyApp", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, dwFlags)
to open a connection to the internet. If successful, this returns a handle (type HINTERNET) to use; otherwise it returns NULL. The flags can include INTERNET_FLAG_OFFLINE to get pages from IE''s cache.

To read a webpage, use hUrl = InternetOpenUrl(hNet, ...), and then call InternetReadFile(hUrl, ...) until the whole page has been read.

When finished with this webpage, call InternetCloseHandle(hUrl). When finished with the web, call InternetCloseHandle(hNet).

InternetOpenUrl() can be used with FTP or Gopher as well as HTTP. Most of this I gleaned from an article Building an Internet Browser Using the Win32 Internet Functions in MSDN. It explains other ways to get files (including getting file-length). OK, so its not a single function call, but I didn''t really expect it to be ;-)

Dave

This topic is closed to new replies.

Advertisement