예제 #1
0
        public static EndPoint NewFreeLocalEndPoint()
        {
            var ip   = NetUtil.GetLocalIPAddresses().FirstOrDefault();
            var port = NetUtil.GetFreeTcpPort(ip);

            return(new EndPoint(ip, port));
        }
예제 #2
0
        public static EndPoint NewFreeLocalEndPoint(int adapterIndex)
        {
            var ip   = NetUtil.GetLocalIPAddresses()[adapterIndex];
            var port = NetUtil.GetFreeTcpPort(ip);

            return(new EndPoint(ip, port));
        }
예제 #3
0
        /// <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;
        }
예제 #4
0
        public static EndPoint NewFreeLocalEndPointSpecifyingPort(int port)
        {
            var ip = NetUtil.GetLocalIPAddresses().FirstOrDefault();

            return(new EndPoint(ip, port));
        }