Lidgren Networking
Homepage: LidgrenHome
Lidgren Network is quite easy to use networking library. It can be used for anykind of software.
I started to work with this library about month ago. Before that, i had never ever done anything that relates to networking.
Setting up chat server was quite easy. After that, i started to think about game server architechture, handling of multiple different kinds of packets, worldState handling, client updating, bandwidth usage.. To be honest, its big task, to build working multiplayer game server and client. You have to handle ever growing amount of different kind of packets. Keep updating clients, with data they need etc. It took me a while to understand all this.
I thought first, that internet must be full of example code, but no.. it's not. Atleast i did not find any. Or if i did, it was so professional code, that i could not even read it.
Things are about to change :)
I created small console based "game", that works over internet, but you can test it on your localhost. When it ask's for IP, just type "localhost". It's very simple example and i tryed to comment it, but feel free to ask help, if something is confusing.
This example covers the very basics of game networking. Message handling, movement, server world state handling etc. Hope you learn something from it.
Here it is: Game Network Example
Thank you very much for your example!
ReplyDeleteImpressive! Maybe write a step-by-step tutorial to not overwhelm beginners?
ReplyDeleteYOU ARE GREAt! ITS FIRST REAL CODE AND TUTORIAL TO LIDGREN I LOVE YOU XD HAHA THKS
ReplyDeleteOMG^^ I love you xD I had a lot of ideas how to handle the diffrent kind of packets i have to send and recieve in my game but none of it works fine and now...finally i found your your code with great comments for every step!! And so it was realy easy to made my game playable over internet! I have to say it again I LOVE YOU XDD
ReplyDeleteThanks very much, after searching the web for a couple hours for a starting point to game networking (in XNA), Lidgren + this sample seems like a really good place to start.
ReplyDeleteThank you! Your a life saver! This is perfect! Easy to understand and quick to get started. Great job.
ReplyDeleteYou're*!
Deletei'm downloading your code and start running with XNA4.0 i face with the window that contain
ReplyDelete"server started"
"Waiting for new connections and updateing world state to current ones"
Ps. Sorry i'm absolute beginner in network please tell some step for me
Try to right click on Client project -> debug select start new instance
ReplyDeleteThis is great, thanks. Just one question. where do you set the IP address the server is listening on?
ReplyDeleteHey thanks for this, going to help me out tons.
ReplyDeleteFor the guy above me, the IP is that of the computer that is running it. If you're running both the server and the client on the same IP, then you can use the "Home" IP which is 127.0.0.1. The port is defined in the server code but you don't need to change this.
Great job Riku! This will help me make a multiplayer racing game on the PSS platform. I'll remember you when things go good with this :D. /cheers
ReplyDeleteDan.
Thanks! This will help a lot.
ReplyDeleteThanks a lot!!...
ReplyDeleteThis was of great help!
ReplyDeleteHow do I get the IP of the host computer to be able to connect too it? I've tired the one on whatismyip.org but it doesn't connect? Any ideas?
ReplyDeleteCheers for this - it has been really helpful!
ReplyDeleteI was just wondering what to type when it asks for an IP address if I'm trying to have the server on one machine and the client on another? Localhost works fine but I can't figure out what is needed to connect between 2 machines!
Warning 1 The primary reference "Lidgren.Network" could not be resolved because it has an indirect dependency on the framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0,Profile=Client". To resolve this problem, either remove the reference "Lidgren.Network" or retarget your application to a framework version which contains "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089". XnaLidgren
ReplyDeleteThis is what i get as a warning when i import the library in an xna game project. I thought that it would not conclude to any other errors but when i try to even insert the classic using Lidgren.Network; and i get an Error 5 The type or namespace name 'Lidgren' could not be found (are you missing a using directive or an assembly reference?). Cannot really conclude to what i should fix to get this working as i have never entered into networking with lidgren. Can comeone please advice me as what i have to do to fix this. Thanks in advance.
http://msdn.microsoft.com/en-us/library/vstudio/cc656912(v=vs.100).aspx
ReplyDeleteYou must change the profile target away from client profile.
http://msdn.microsoft.com/en-us/library/vstudio/bb398202(v=vs.100).aspx
Awesome job! Well done helped me a lot! Thanks!
ReplyDeleteI will try to upgrade it to an xna working example.
would be awesome if you'd share that example :)
DeleteInteresting, at first I didn't understand that the A,S,W,D was being sent back to the client over the network. It look like it was not working.....might want to clarify that?
ReplyDeleteI am receiving a "Strange Message" error.
ReplyDeleteAny workarounds?
Keep getting the same message too. I'm trying localhost and open my ports. Did someone know what happens here?
DeleteFor some reason I cannot get this to work from 2 PC's across the internet....do I need to open the port on my router or firewall ??
ReplyDeleteIt works, as long as the Server side uses Port Forwarding UDP, for the assigned port. Works very well !!
ReplyDeleteHey, I gotta say, your example is dead simple and straight forward. it has been really helpful in thinking of how to parse msgs.
ReplyDeleteGlad I finally found your page -- a nice example that explains everything I need to get started. Thanks
ReplyDeleteNice place to start learning lidgren.
ReplyDeleteThis works when I'm connecting clients and the server in one computer, but I want to able to connect with two computers.
Tried opening a client for both computer and a server in one of them but that doesn't work, do I need to change something in the code or is there an external problem?
Thanks for your example, it's very-very helpfull
ReplyDeleteThanks for this! :)
ReplyDeleteThanks and I have a dandy offer: How Much Budget For House Renovation house renovation toronto
ReplyDelete