This commit is contained in:
Jordan Brown
2020-05-15 22:28:01 -04:00
parent 80dff9a456
commit e7404fea37
@@ -112,6 +112,24 @@ namespace Tgstation.Server.Host.Components.Session
};
}
/// <summary>
/// Check if a given <paramref name="port"/> can be bound to.
/// </summary>
/// <param name="port">The port number to test.</param>
static void PortBindTest(ushort port)
{
using var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
try
{
socket.Bind(new IPEndPoint(IPAddress.Loopback, port));
}
catch (Exception ex)
{
throw new JobException(ErrorCode.DreamDaemonPortInUse, ex);
}
}
/// <summary>
/// Construct a <see cref="SessionControllerFactory"/>
/// </summary>
@@ -425,23 +443,5 @@ namespace Tgstation.Server.Host.Components.Session
if(otherUserName.Equals(ourUserName, StringComparison.Ordinal))
throw new JobException(ErrorCode.DeploymentPagerRunning);
}
/// <summary>
/// Check if a given <paramref name="port"/> can be bound to.
/// </summary>
/// <param name="port">The port number to test.</param>
static void PortBindTest(ushort port)
{
using var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
try
{
socket.Bind(new IPEndPoint(IPAddress.Loopback, port));
}
catch (Exception ex)
{
throw new JobException(ErrorCode.DreamDaemonPortInUse, ex);
}
}
}
}