- Home /
Using UPnP with Unity Networking?
Hello, i am wondering if it is possible to use UPnP to directly open ports to allow clients to communicate to a server. I am not sure how the NAT punch through works, but if it is similar i wouldn't mind a description of how it works!
I found this article that demonstrates upnp in .net using a windows library: http://pietschsoft.com/post/2009/02/05/NET-Framework-Communicate-through-NAT-Router-via-UPnP
UPDATE: I found this library, and this could possibly be used to do this, as it works with .net and mono. https://github.com/lontivero/Open.Nat
Thankyou.
If you don't need an authoritative server, you could use Photon Unity Networking which would get rid of the need to use NAT punching.
Yeah Photon is not something i can use, which is why i am looking into better ways to allow connections to server hosts.
hi, were you able to get the library working with unity, i have an issue where it only works in the editor and not in a build. it crashes when i open the build of a game.
Answer by jpthek9 · Jan 10, 2015 at 05:15 PM
I suggest you use Photon Unity Networking which is an excellent SDK that gets rid of a lot of the needless technical aspects of networking. Also, it has Reliable UDP which is a very useful protocol to ensure proper packet sending. Check it out here: https://www.exitgames.com/PUN. You just install the plugin and follow this guide: http://doc.exitgames.com/en/pun/current/tutorials/tutorial-marco-polo to get you started.
It's really quite similar to Unity networking and many of the methods share the same name.
From what i know, PUN does not allow you to host a local server yourself, which is what i wish for any client to be able to do. I'm not even sure if it allow multiple private servers to be hosted via their online service.
No it doesn't. If that is something you need, that it unfortunately not an option. You can, however, simulate a local server with a player but this leads to vulnerability for hacking.