基本信息
源码名称:C# 单机网络监听 实例源码
源码大小:0.40M
文件格式:.rar
开发语言:C#
更新时间:2014-11-17
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍
可实现本机TCP or udp网络监听


 

  private void btnStart_Click(object sender, EventArgs e)
        {
            //开始抓取数据包
            if (btnStart.Text == "开始抓取")
            {
                //循环抓取每个网卡的数据包
                for (int i = 0; i < packetMonitor.Length; i )
                {
                    if (cmbIpList.SelectedIndex == 0)
                    {
                        try
                        {
                            //第i个开始抓取
                            packetMonitor[i].begainMonitor();
                        }
                        catch
                        {
                            MessageBox.Show("内部错误,请联系管理员");
                        }
                    }
                    else
                    {
                        try
                        {
                            //抓取指定的Ip
                            packetMonitor[cmbIpList.SelectedIndex - 1].begainMonitor();
                        }
                        catch
                        {
                            MessageBox.Show("内部错误,请联系管理员");
                        }
                    }
                    btnStart.Text = "停止抓取";
                    toolStripStatusLabel1.Text = "开始监测所有端口";
                }     
            }
            //停止抓取
            else
            {
                for (int i = 0; i < packetMonitor.Length; i )
                {
                    packetMonitor[i].Stop();
                }
                btnStart.Text = "开始抓取";
                toolStripStatusLabel1.Text = "停止监测";
            }
       
        }