Ejemplo n.º 1
0
        public static void ScanIP(Action <ScanResult> callback, Action <int, int, int> progress, CancellationToken ct, int port, IPAddress paramIP = null)
        {
            int count = 0;

            if (callback == null)
            {
                throw new ArgumentNullException(string.Format("Callback needed"));
            }
            if (progress == null)
            {
                throw new ArgumentNullException(string.Format("Progress needed"));
            }

            var localIP = paramIP ?? IPAddressHelper.GetLocalIP();

            if (localIP == null)
            {
                throw new Exception(string.Format("Can't find network adapter for IP {0}", paramIP));
            }
            var localMask = localIP.GetSubnetMask();

            if (localMask == null)
            {
                throw new Exception(string.Format("Can't find subnet mask for IP {0}", localIP));
            }

            IPSegment        segment = new IPSegment(localIP, localMask);
            IPSegmentScanner scanner = new IPSegmentScanner(segment, callback, progress, port, ct);

            scanner.FastScan();
            //scanner.FullScan();
        }
Ejemplo n.º 2
0
        public IPSegmentScanner(IPSegment segment, Action <IPAddressHelper.ScanResult> callback, Action <int, int, int> progress, int port, CancellationToken ct)
        {
            mList = new List <IPAddressHelper.ScanResult>();

            mSegment  = segment;
            mCallback = callback;
            mProgress = progress;
            mCt       = ct;
            mPort     = port;
        }