/// <summary> /// Initializes /// </summary> /// <param name="ep"></param> /// <param name="strategy"></param> public EndPointHostBase(EndPoint ep, LogicOfTo <string, string> logic = null) : base() { Condition.Requires(ep).IsNotNull(); //validate the ep is within the current ip list var ips = NetUtil.GetLocalIPAddresses(); Condition.Requires(ips).Contains(ep.IPAddress); this.EndPoint = ep; this.Logic = logic; }
public static EndPoint NewFreeLocalEndPointSpecifyingPort(int port) { var ip = NetUtil.GetLocalIPAddresses().FirstOrDefault(); return(new EndPoint(ip, port)); }
public static EndPoint NewFreeLoopbackEndPoint() { int port = NetUtil.GetFreeTcpPort(System.Net.IPAddress.Loopback); return(new EndPoint(System.Net.IPAddress.Loopback, port)); }