C#ɨÃè¼ÆËã»ú¶Ë¿Ú
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace PortScanner
{
class Program
{
¡¡//ÒÑɨÃè¶Ë¿ÚÊýÄ¿
¡¡internal static int scannedCount = 0;
¡¡//ÕýÔÚÔËÐеÄÏß³ÌÊýÄ¿
¡¡internal static int runningThreadCount = 0;
¡¡//´ò¿ªµÄ¶Ë¿ÚÊýÄ¿
¡¡internal static List<int> openedPorts = new List<int>();
¡¡//ÆðʼɨÃè¶Ë¿Ú
¡¡static int startPort = 1;
¡¡//½áÊø¶Ë¿ÚºÅ
¡¡static int endPort = 500;
¡¡//×î´ó¹¤×÷Ïß³ÌÊý
¡¡static int maxThread = 10;
¡¡static void Main(string[] args)
¡¡{
¡¡¡¡//½ÓÊÕ´«Èë²ÎÊýÒ»×÷ΪҪɨÃèµÄÖ÷»ú
¡¡¡¡string host = "192.168.0.1";
¡¡¡¡//½ÓÊÕ´«Èë²ÎÊý¶þ×÷Ϊ¶Ë¿ÚɨÃ跶Χ£¬Èç1-4000
¡¡¡¡string portRange = "1-400";
¡¡¡¡startPort = int.Parse(portRange.Split('-')[0].Trim());
¡¡¡¡endPort = int.Parse(portRange.Split('-')[1].Trim());
¡¡¡¡for (int port = startPort; port < endPort; port++)
¡¡¡¡{
¡¡¡¡¡¡//´´½¨É¨ÃèÀà
¡¡¡¡¡¡Scanner scanner = new Scanner(host, port);
¡¡¡¡¡¡Thread thread = new Thread(new ThreadStart(scanner.Scan));
¡¡¡¡¡¡thread.Name = port.ToString();
¡¡¡¡¡¡ thread.IsBackground = true;
¡¡¡¡¡¡//Æô¶¯É¨ÃèÏß³Ì
¡¡¡¡¡¡thread.Start();
¡¡¡¡¡¡runningThreadCount++;
¡¡¡¡¡¡Thread.Sleep(10);
¡¡¡¡¡¡//Ñ»·£¬Ö±µ½Ä³¸öÏ̹߳¤×÷Íê±Ï²ÅÆô¶¯ÁíÒ»ÐÂỊ̈߳¬Ò²¿ÉÒÔ½Ð×öÍÆÀ´°¼¼Êõ
¡¡¡¡¡¡while (runningThreadCount >= maxThread) ;
¡¡¡¡}
¡¡¡¡//¿ÕÑ»·£¬Ö±µ½ËùÓж˿ÚɨÃèÍê±Ï
¡¡¡¡while (scannedCount + 1 < (endPort - startPort)) ;
¡¡¡¡¡¡Console.WriteLine();
¡¡¡¡¡¡Console.WriteLine();
¡¡¡¡¡¡//Êä³ö½á¹û
¡¡¡¡¡¡Console.WriteLine("Scan for host: {0} has been completed , \n total {1} ports scanned, \nopened ports :{2}",
host, (endPort - startPort), openedPorts.Count);
¡¡¡¡foreach (int port in openedPorts)
¡¡¡¡¡¡Console.WriteLine("\tPort: {0} is open", port.ToString().PadLeft(6));
¡¡}
}
//ɨÃèÀà
class Scanner
{
¡¡string m_host;
¡¡int m_port;
¡¡
¡¡public Scanner(string host, int port)
¡¡{
¡¡¡¡m_h
Ïà¹ØÎĵµ£º
¡¡¡¡Bin Ŀ¼ÓÃÀ´´æ·Å±àÒëµÄ½á¹û£¬binÊǶþ½øÖÆbinraryµÄÓ¢ÎÄËõд£¬ÒòΪ×î³õC±àÒëµÄ³ÌÐòÎļþ¶¼ÊǶþ½øÖÆÎļþ£¬ËüÓÐDebugºÍReleaseÁ½¸ö°æ±¾£¬·Ö±ð¶ÔÓ¦µÄÎļþ¼ÐΪbin/DebugºÍbin/Release£¬Õâ¸öÎļþ¼ÐÊÇĬÈϵÄÊä³ö·¾¶£¬ÎÒÃÇ¿ÉÒÔͨ¹ý£ºÏîÄ¿ÊôÐÔ—>ÅäÖÃÊôÐÔ—>Êä³ö·¾¶À´Ð޸ġ£
¡¡¡¡objÊÇobjectµÄËõд£¬ÓÃÓÚ´æ·Å ......
ͨ¹ý·´É䣬µÃµ½Õë¶Ôijһö¾ÙÀàÐ͵ÄÃèÊö¡£
ö¾ÙµÄ¶¨ÒåÖмÓÈëÃèÊö
using System;
using System.Collections;
namespace Ahnlab.ApplicationServices
{
public sealed partial class SysEnums
{
#region ϵͳ¹ÜÀíÄ£¿éµÄö¾ÙÐÅÏ¢
/// <summary>
/// ÔÚÏß²»Á¼Åâ³ ......
ÏëÌá¸ßc#±à³Ìˮƽ£¿ÏÂÃæÕâ50Ìõ¾Ñé²»¿É²»¶Á£¡
Ìá¸ßC#±à³ÌˮƽµÄ50¸öÒªµã
1.×ÜÊÇÓÃÊôÐÔ (Property) À´´úÌæ¿É·ÃÎʵÄÊý¾Ý³ÉÔ±
2.ÔÚ readonly ºÍ const Ö®¼ä£¬ÓÅÏÈʹÓà readonly
3.ÔÚ as ºÍ Ç¿ÖÆÀàÐÍת»»Ö®¼ä£¬ÓÅÏÈʹÓà as ²Ù×÷·û
4.ʹÓÃÌõ¼þÊôÐÔ (Conditional Attributes) À´´úÌæÌõ¼þ±àÒëÓï¾ä #if
5.×ÜÊÇΪ×Ô¶¨Ò ......
ͨ³£ÎÒÃÇÔÚ³ÌÐòÖÐÐèÒªµ÷ÓÃWebServiceʱ£¬¶¼ÊÇͨ¹ý“Ìí¼ÓWebÒýÓÔ£¬ÈÃVS.NET»·¾³À´ÎªÎÒÃÇÉú³É·þÎñ´úÀí£¬È»ºóµ÷ÓöÔÓ¦µÄWeb·þÎñ¡£ÕâÑùÊÇʹ¹¤×÷¼òµ¥ÁË£¬µ«ÊÇÈ´ºÍÌṩWeb·þÎñµÄURL¡¢·½·¨Ãû¡¢²ÎÊý°ó¶¨ÔÚÒ»ÆðÁË£¬ÕâÊÇVS.NET×Ô¶¯ÎªÎÒÃÇÉú³ÉWeb·þÎñ´úÀíµÄÏÞÖÆ¡£Èç¹ûÄÄÒ»Ìì·¢²¼Web·þÎñµÄURL¸Ä±äÁË£¬ÔòÎÒÃÇÐèÒªÖØÐÂÈÃVS.NE ......