Exemple #1
0
        public static List <IPEndPoint> Find(string ipRange, int startingPort, int endingPort, int connectTimeout = 100)
        {
            if (startingPort > endingPort)
            {
                throw new ArgumentException();
            }

            List <IPEndPoint> endpoints = new List <IPEndPoint>();

            List <IPAddress> ipAddresses = new IPRange(ipRange).GetIPAddresses().ToList();

            //optimize until we need otherwise
            ipAddresses.RemoveAll(ip => ip.ToString().Equals(LocalNetwork.GetLocalIPAddress()));
            ipAddresses.RemoveAll(ip => ip.ToString().EndsWith(".0"));

            foreach (IPAddress ipAddress in ipAddresses)
            {
                for (int currentPort = startingPort; currentPort <= endingPort; currentPort++)
                {
                    if (IsPortOpen(ipAddress, currentPort, connectTimeout))
                    {
                        endpoints.Add(new IPEndPoint(ipAddress, currentPort));
                    }
                }
            }

            return(endpoints);
        }
Exemple #2
0
        public static List<IPEndPoint> Find(string ipRange, int startingPort, int endingPort, int connectTimeout = 100)
        {
            if (startingPort >= endingPort)
                throw new ArgumentException();

            List<IPEndPoint> endpoints = new List<IPEndPoint>();

            IEnumerable<IPAddress> ipAddresses = new IPRange(ipRange).GetIPAddresses();

            foreach (IPAddress ipAddress in ipAddresses)
                for (int currentPort = startingPort; currentPort <= endingPort; currentPort++)
                    if (IsPortOpen(ipAddress, currentPort, connectTimeout))
                        endpoints.Add(new IPEndPoint(ipAddress, currentPort));

            return endpoints;
        }
Exemple #3
0
        public static List<IPEndPoint> Find(string ipRange, int startingPort, int endingPort, int connectTimeout = 100)
        {
            if (startingPort > endingPort)
                throw new ArgumentException();

            List<IPEndPoint> endpoints = new List<IPEndPoint>();

            List<IPAddress> ipAddresses = new IPRange(ipRange).GetIPAddresses().ToList();

            //optimize until we need otherwise
            ipAddresses.RemoveAll(ip => ip.ToString().Equals(LocalNetwork.GetLocalIPAddress()));
            ipAddresses.RemoveAll(ip => ip.ToString().EndsWith(".0"));

            foreach (IPAddress ipAddress in ipAddresses)
                for (int currentPort = startingPort; currentPort <= endingPort; currentPort++)
                    if (IsPortOpen(ipAddress, currentPort, connectTimeout))
                        endpoints.Add(new IPEndPoint(ipAddress, currentPort));

            return endpoints;
        }