Unity-Technologies / com.unity.netcode.gameobjects

Netcode for GameObjects is a high-level netcode SDK that provides networking capabilities to GameObject/MonoBehaviour workflows within Unity and sits on top of underlying transport layer.
MIT License
2.15k stars 435 forks source link

Access to the socket or a function to send UDP directly to an IP and port #3041

Closed SubatomicPlanets closed 2 months ago

SubatomicPlanets commented 2 months ago

I am working on my custom NAT hole punching solution. I have a C++ server running, and I tested it with Python clients. Everything worked fine, so I started implementing the client in Unity. But it seems this is impossible due to something very simple:  Netcode for GameObjects does not have any function for sending something to an IP and port.  I know that this might be more related to Unity Transport, but I don't know where else to write this. I can't open a new socket because it has to be on the same port as the hosts socket. So I need to send some UDP message to an IP address and port from the hosts socket itself.

The best solution would be to somehow expose this socket or a function that lets you send stuff to an IP and port.

Please correct me if I'm wrong. I've been trying to figure this out for a few days now. Thanks!

SubatomicPlanets commented 2 months ago

Sorry, I think my understanding of how NAT hole punching works was wrong. I think I can use another source port. I will close this issue.