- Home /
Unet & Mono.Nat
Personally, I can't stand cloud hosted servers that I don't get to set up myself. Due to this, I didn't want to use Unity Multiplayer but I liked the ease of use of Unet. Due to this I did a bunch of reading on how I could get around it.
In the end I found this forum post: Forum Post
Which offered an interesting solution, To use Mono.NAT to preform a nat punch through on a lan game and then set up a custom server list. Now the tutorials linked on how to set up mono.NAT are very straight forward but I am unsure as to where abouts I need to put the code?
I assume its somewhere in the network manager script but I don't know where exactly.
Any help is greatly appreciated.
Signed, Vandie
So, you had the mono.nat dll in the root of your assets folder and the punchthrough.cs file in the root of you assets folder, not attached to anything, and it just worked?
I can't seem to get this setup to work on $$anonymous$$e.
Answer by Vandie_Studios · Sep 01, 2015 at 05:34 PM
Ok turns out that all I had to do was create a new c# file that was purely the following code:
using Mono.Nat;
public class punchthrough {
public punchthrough(){
NatUtility.DeviceFound += DeviceFound;
NatUtility.DeviceLost += DeviceLost;
NatUtility.StartDiscovery ();
}
private void DeviceFound(object sender, DeviceEventArgs args)
{
INatDevice device = args.Device;
device.CreatePortMap(new Mapping(Protocol.Tcp, 2033, 2033));
// on device found code
}
private void DeviceLost(object sender, DeviceEventArgs args)
{
INatDevice device = args.Device;
device.DeletePortMap(new Mapping(Protocol.Tcp, 2033, 2033));
// on device disconnect code
}
}
I sent the file to a few others and it appears to punch through fine on port 2033
Answer by TwistedSage · Mar 06, 2016 at 02:44 PM
Hi. I just startet to look into Mono.NAT.
Once the port map is done, do I host the server on the internal IP (I create the port mapping like this: device.CreatePortMap(new Mapping(Protocol.Tcp, 25000, 25000));) (or just 127.0.0.1) and then tell people to connect through the IP I get from device.GetExternalIP().ToString()?
Thanks in advance :)
Your answer
Follow this Question
Related Questions
Networking Example Doesnt Connect 0 Answers
Symmetric Nat Punchthrough Problem 1 Answer
What is NAT Punchthrough - Android 1 Answer
How To Client Connect Player Host Via Public Ip 0 Answers
Mono library to connect to Java/Python/Node backend? 1 Answer