Sign in to follow this  

Beginner networking questions

This topic is 2537 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

Hi

I have made several games in c++ but im completely new to network programming. Some Qs:

1. Im working on a turn-based strategy game where players take turns moving units around in a tile-based world (like advanced wars, early civ etc). What is the best basic procedure for handling this? Should each player hold a complete copy of all units and all terrain? When a player wants to move a unit, should i send a move-command to the server, and it tells all clients to move the specific unit? Should the players client move it first and then itself tell all other clients to move "their" units as well?

2. I've looked into network engines and think raknet could be good. I look for simplicity foremost (and it needs to be free for non-commercial projects). Any other suggestions? I dont need very advanced features as far as I understand.

3. I would like to setup some kind of lobbyserver. If i dont, players must connect to each other by typing in the ip-nr of the guy hosting each game right? Is there any free services for lobbyservers or do i need to buy one? The game will still run with one user as the server once a match launches, the lobby-server thing will only serve as a mean for players playing my game to find each other.

Thanks for your input
Erik

Share this post


Link to post
Share on other sites
First off, I'm along way from networking in my programming practice, but I think each player must keep a local copy of each unit, else the server will need to send a message to each client for each mouse over or click that that player would make(to get stats, legal moves, etc). the server would also keep a copy of the game, and it would be the authority on combat and what not(and could be a client itself).

I believe your intuitions are correct, a command structure seems well suited to this. The player could send a command to the server, which would update all other clients.

I've seen many positive reviews of Raknet, again, I've never used it.

I assume your clients could connect via post 80, and you could use a regular http host and some nifty php or other to handle a simple chat/game server, and then pass over control of the game to the server itself.

Share this post


Link to post
Share on other sites
Thanks guys

You might (for my question 3) refer to
"If your game is networked over the internet, but uses user-hosted servers, then you need a matchmaking/lobbying/introduction service. The service itself lives at a known DNS name; hosts and clients connect to this server to register/query the database of active hosted games. You may also be interested in NAT punch-through in this case; see previous questions in this FAQ."

But that doesnt really explain how i can do it. Is there free lobby servers around? Or i need to do that trick with http? You mean a homepage where you simply find other players and then launch the game and punch in their ip-nr?

Thanks again
Erik

Share this post


Link to post
Share on other sites
The FAQ goes on to link to some articles about NAT punch-through, which in turn say that you have to host your own process for that to work. Hosting your own process generally means paying for virtual server hosting, although you can get a year of a free Amazon ECC micro instance by just signing up for their service (software not included).

For lobbies where you don't worry about punch-through (so users have to port forward), a regular web home page with a database would probably be sufficient.

Share this post


Link to post
Share on other sites
but its not enough to write (code) the lobby, the problem is that i need an actual server running all the time. And i need to pay for it it seemes. I guess i can use my own computer for that somehow, but thats a pretty crappy solution since its not always on (the game im planning will not need any high traffic capacity though).

Hooking players up in the game by knowing your friend is playing also right now and calling him and punching in his IP-nr isnt very convinient...

E

Share this post


Link to post
Share on other sites
Quote:
Original post by suliman
1) but its not enough to write (code) the lobby, the problem is that i need an actual server running all the time.
2) And i need to pay for it it seemes.
3) I guess i can use my own computer for that somehow, but thats a pretty crappy solution since its not always on (the game im planning will not need any high traffic capacity though).
4) Hooking players up in the game by knowing your friend is playing also right now and calling him and punching in his IP-nr isnt very convinient...
Basically correct.

1) Yes, for a lobby that runs 24/7 you need an actual server available 24/7. The server doesn't need to do much, and it can be as simple as a little web page script that is nearly always idle. Of course it can also be a super-deluxe suite of applications running on a cluster of machines, but you described a different need.

2) Somebody needs to pay for it. Presumably it is you, but if you can find a hosting solution that will pay for it, kudos to you. A little creative writing of web page scripts with a lightweight data backend provided by a 'free' web host might be a viable solution for you. Or it might not, I really don't know your situation.

3) You can use your own computer if it meets the requirements. Technically it isn't hard: It must be publicly accessible by the global Internet (your players), it must be available (not under a DDoS attack or using all your bandwidth watching movies online) and must be running your server when your users want to reach it (hopefully obvious). You should also verify with your ISP that the use is allowed; many big-name companies prefer a download-only version of the Internet and have TOS agreements that forbid running servers without a more expensive 'business' connection.

4) Typing in their IP address is certainly a valid solution. Many games allow it in addition to public lobby access, and it is frequently found in older games before public lobbies were commonplace. You can make it a little easier by sending network broadcasts in search of a running game and by providing connection info for LAN players. Directly-entered IP addresses is a very useful thing to have during your own testing and development. It does not help you with problems of NAT punch-through, but is often a very useful feature, providing convenience rather than taking it away.

[Edited by - frob on January 2, 2011 3:31:15 AM]

Share this post


Link to post
Share on other sites
Ok thanks for all the helpful info.

My project is completely for fun only so i will not have any budget. I will look into sollutions to do it the way you describe, or simply use writing IP adresses manually.
The problem with that is that you will only ever play people you hook up with "outside the game", ergo your friends. Youi mension some way of broadcasting, i will try to look into this and see what i understand:)

E

Share this post


Link to post
Share on other sites

This topic is 2537 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this