help a noobie

Started by
9 comments, last by hplus0603 17 years, 7 months ago
After programming several games, i want to learn winsock, so that i can make a simple multiplayer game. I don't want to make a MMORPG, actually, i want to make just a simple chatroom application. This will be like my "hello world" for multiplayer.Also, i want this to be a server /client setup (as my future gamees would have this kind of setup) and programed in c++ my real question is: Lets say i have a dedicated server on one of my old computers that runs everyday. I was told that my IP address changes (im not shutting off the computer). So how do you code in the clients application, to deal with this change. If i hardcode the ip address and the servers ip address changes, then obviously the client's app won't connect. How do you guys get around this? is my servers fault for changing ip addresses? if so is there a way to stop that? what are the techniques that you guys use? thanks in advance
Advertisement
Quote:Original post by wizardpc
I was told that my IP address changes (im not shutting off the computer). So how do you code in the clients application, to deal with this change.

I don't think the IP will change if you keep the computer running.

Quote:Original post by wizardpc
is my servers fault for changing ip addresses? if so is there a way to stop that?

I think you Internet Service Provider is the cause of that. But it is easy to test. goto www.myip.dk and see what IP you have. Shut down your computer and boot again. Enter page. Is IP the same? (If you have modem, then just disconnect and connect again).
-------------Ban KalvinB !
yes thats what i ment, the internet service provider changes my ip. I have a cable connection if that helps.


i don't understand what you mean by page.

i know you might also tell me that, its not going to change in the amount of time the chat program is running, since this is just a testing purpose, but i wanted to know because i do plan eventually having a game with up to 8 players (just my friends playing it) where they can log onto the server, play, leave. and resume where they took off at a later date. So i want to make sure my clients can connect to my server, because i have work and school most of the day.

i know how to find my ip address, but my real question is, how does one code the client app for this ?


thanks,

p.s. if i was to stupid to see the answer in the above post, my apologizies
sorry about the above post, that was me


I forgot i was at school right now, lol, so it didn't auto-log me into gamedev :)
The likely answer is to connect to a computer name, not an IP. If you're running it on a Windoze network I think you can use the computer name (as in what you see in Network Places or whatever it's called). Over the Internet, you'll have a computer name like myloginname.isp.net (example: bobjanova.demon.co.uk) and you can connect to that.
One option is to get a DSL/Cable Router. If the ISP changes the IP it will just be on the router. Then you can assign IP addresses to each computer using 192.168.x.x. Or go into the router and enter your computers MAC so it always gets the same DHCP address.

If you are running a server OS (Win2k, Win2k3, *nix) on one of you computesr in the LAN, you could set up DNS with a fake domain and use DNS resolution.
The problem with a router is that, while it keeps your IP constant within the network, it still doesn't help anyone outside the network.

Quote:I don't think the IP will change if you keep the computer running.


Actually, it may very well -- the DHCP server doesn't have to renew your lease, but can instead give you another IP address. Some cable providers allow you to get a static IP, for a fee, btw.

The solution to a potentially changing DNS set-up is dynamic DNS. For example, DynDns. Set your machine to update your record every 30 minutes, and your service won't be down because of an IP change for more than 30 minutes, when it happens.
enum Bool { True, False, FileNotFound };
Quote:Original post by hplus0603
Actually, it may very well -- the DHCP server doesn't have to renew your lease, but can instead give you another IP address. Some cable providers allow you to get a static IP, for a fee, btw.

Really? So in the middle of a game of BF2 the IP suddenly changes and you are disconnected? I have a hard time believing that. Or is it only if you have NO open connections?

-------------Ban KalvinB !
Quote:Really? So in the middle of a game of BF2 the IP suddenly changes and you are disconnected? I have a hard time believing that. Or is it only if you have NO open connections?


im not sure about this but to my knowledge yes the servers ip adress is reevaluated (not necessarily changed) roughly every three days and when it changes because on a game life BF2 the server has a registered domain name DNS prototcols can kick in and retrieve the new IP address from the nearest server that has it chached and reestablish the connection in 500-1000 miliseconds
The best way to see if your ISP changes your IP address is to monitor it. Check it for a week and see if it changes or not. The way DHCP works is that during the lease time your machine will periodically check in with the DHCP server to renew the address. If it is successful in renewing the address then it will extend the lease to the maximum allowed.

So you really shouldn't get a new address unless your PC/router is powered off or you manually release your current address.

This topic is closed to new replies.

Advertisement