Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

My use of terminology may be off a little bit. I have been playing around with the Lidgren XNA sample for how the library works, and it is simple to implement it looks like.

I am curious on the logic or theory behind making the game client also act as a server? Basically I want a user to open the game client and have the option of "Hosting a Game" which would allow others to connect to that computer and play multiplayer.

It was suggested that I use some sort of thread to kick off the server code in the background for that host client and then connect the two pieces together for full functionality.

share|improve this question
1  
"It was suggested that I use some sort of thread to kick off the server code in the background for that host client and then connect the two pieces together for full functionality." This is exactly how hosting your own game should work. Just a second thread or a new process on the host's machine that he can then join himself as well. –  Roy T. Mar 15 '12 at 20:01
    
Thanks Roy, I was just unsure if that is exactly what I need to be looking for. I have found in the past I think I am researching what I need, but in fact the process I am trying to complete has a more specific name. When I was trying to find code for client / server networking, I was blissfully ignorant of the client server part of that statement. –  sec_goat Mar 15 '12 at 20:07
    
@RoyT. you should make that answer. sec_goat what Roy said is exactly how ID (Quake, Doom, etc.) does things and it works really well for them: you simply reject connection from anything other than 127.0.0.1 for single player mode; or if you can abstract your network layer under an abstraction layer you can write a link-local socketless implementation. –  Jonathan Dickinson Mar 16 '12 at 9:13
    
Jonathan, thanks for that answer, I would mark his comment as the answer but I don't think I can. Still A little new here. Thank you for giving me some things to think about, a lot of times if I have some idea of what I am trying to do, terminology-wise, I can end up finding my way to the solution. –  sec_goat Mar 16 '12 at 12:24
    
Jonathan Dickinson: at first I thought it was too short for a real answer but since no-one else posted an answer yet I followed your advice. –  Roy T. Mar 16 '12 at 19:03

1 Answer 1

up vote 0 down vote accepted

This is a quote of my comment earlier so this question can be resolved:

"It was suggested that I use some sort of thread to kick off the server code in the background for that host client and then connect the two pieces together for full functionality." This is exactly how hosting your own game should work. Just a second thread or a new process on the host's machine that he can then join himself as well.

share|improve this answer
    
So far so good with this theory. I have a client that also kicks off the server portion and all is well. Need to flesh out the code a little more, but just hearing the idea behind what I need to do helps a lot. Thanks! –  sec_goat Mar 21 '12 at 13:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.