22 lines
491 B
C#
22 lines
491 B
C#
using System.Net;
|
|
using System.Net.Sockets;
|
|
|
|
namespace Dada.Supervisor;
|
|
|
|
internal static class LoopbackPortGuard
|
|
{
|
|
internal static SupervisorState Check()
|
|
{
|
|
try
|
|
{
|
|
using var listener = new TcpListener(IPAddress.Parse(LoopbackEndpoint.Host), LoopbackEndpoint.Port);
|
|
listener.Start();
|
|
return SupervisorState.Starting;
|
|
}
|
|
catch (SocketException)
|
|
{
|
|
return SupervisorState.PortInUse;
|
|
}
|
|
}
|
|
}
|