Getting Started with Networking

Started by
3 comments, last by nooblet 12 years ago
Hey everybody!

So, I've been learning C# for the past few months, and finally migrated towards learning some XNA to remake a Pong clone. I've made Pong in the past, but using C++ and SDL, so this was another learning experience. However, this time, I've added extra "features" to the game, and what I mean by that, is I've actually incorporated a menu system, winning and losing, beatable A.I., and sound effects which I've never done before.

I found the process incredibly fun and the motivation for game development came back to me. Now, I know this may be a bit overambitious, but I'm very interested in adding networking into the game. I don't plan on doing development for Xbox 360 or Windows Phone, so my networking options aren't available within the XNA framework itself.

I'm thinking of adding a P2P connection so that players can host/join lobbies and compete against each other. I could also implement a high scoring system to show who has the most amount of points currently, just to encourage some friendly competition among my friends. So, I did some research and found out about Lidgren, but it appears that the library is currently only for a client/server network, and it appears to be extremely complicated with not too many resources available (although I could be searching in the wrong area).

I noticed there was the System.Net.PeerTopeer namespace that I could use, but again, I didn't find many examples of using that either. Would anybody happen to have suggestions for dabbling into networking for the first time, or should I just worry about finishing up my game and start working on another clone such as Breakout or Tetris?

I appreciate the help guys and gals!
Advertisement
I reckon you should start by just making the pong game itself networked (i.e. streaming bat and ball positions etc...). P2P is quite a different beast from your standard client/server model so I would start by learning client/server first and then dabble into P2P. Also, P2P doesn't really work well when it comes to storing scoreboards etc... because you need to centralize it somehow. From your description what you're probably thinking of is a public server model where the server can be freely used by anybody to create their own lobbies, (which remains client/server). P2P describes a situation where everybody is simultaneously a client and a server (so for file sharing applications for instance, this is the case because everybody is streaming stuff to everyone - or at least a large number of people), even if they may not physically be "hosting" the connection.

I would say the lobby project is a bit too ambitious unless you really want to learn networking. I would just implement a basic multiplayer pong first, and then move on to breakout or tetris (I would recommend tetris as it's a bit more involved than breakout and there's also the possibility of making it 3D in case you want to check that out).

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

Thanks for the suggestions! I'm very interested in learning some networking, mainly due to my goal to eventually make my own little instant messenger application in the future. Do you happen to know where one could find some examples/tutorials for using Lidgren to create a server and having the client interact with the server? I have a very small understanding on how it works, but I definitely need more information. Appreciate the feedback thus far!

Thanks for the suggestions! I'm very interested in learning some networking, mainly due to my goal to eventually make my own little instant messenger application in the future. Do you happen to know where one could find some examples/tutorials for using Lidgren to create a server and having the client interact with the server? I have a very small understanding on how it works, but I definitely need more information. Appreciate the feedback thus far!

I don't do much C#, but when I was learning sockets I just used the standard berkeley socket implementations (winsock for windows, socket for linux). If you stick to blocking sockets it really isn't that bad. That said this is just for learning and understand how it works - you will definitely need to use some kind of library if you want to do more complicated stuff.

Lidgren has a few basic tutorials on their google page but I assume you've already checked them out: http://code.google.com/p/lidgren-network-gen3/wiki/Basics

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

Thanks so much for your help! I'll see if I can't get something up and running :).

This topic is closed to new replies.

Advertisement