How To Check if Port is being used?

This method here works fine when I am testing locally, but once I put it up on the fleet it doesn’t seem to work.

https://gist.github.com/herpdederp/34f15e923a2cece09c5acda0b5220211

Yup my port checking was running at the same time at start for each process, nevermind

I will debug it further to see what result is actually happening. Maybe I am mistaken with how GameLift handles processes, I am wondering if each instance is set to 2 processes, these processes are on standby until a game session is created or something else.

What failures are you seeing? What are you trying to do exactly?

If you are trying to find a free port for the server, you can just pass in port assignments in your runtime configuration ie --port 12345 and have the server bind to this port.

If you need to scan for open ports, theres plenty of alternatives here: https://stackoverflow.com/questions/138043/find-the-next-tcp-port-in-net

If you are just checking if the port is free, then C# offers multiple ways of doing this and you may want to look at the documentation around expected behaviour and failure modes.