C#.net同步异步SOCKET通讯和多线程总结(11)

来源:未知 责任编辑:责任编辑 发表时间:2014-01-06 18:18 点击:

                   }

             }

              base.Dispose( disposing );

         }

TCP协议的发送端

using System.Net.Sockets; //使用到TcpListen类

using System.Threading; //使用到线程

using System.IO; //使用到StreamWriter类

using System.Net; //使用IPAddress类、IPHostEntry类等

          private StreamWriter swWriter; //用以向网络基础数据流传送数据 

         private.NetworkStream nsStream; //创建发送数据的网络基础数据流 

         private TcpClient tcpClient;

         private System.Windows.Forms.Button button1;

         private System.Windows.Forms.TextBox textBox1;

         private System.Windows.Forms.Button button2;

         private System.Windows.Forms.TextBox textBox2;

         private System.Windows.Forms.StatusBar statusBar1;

         private System.Windows.Forms.Label label1;

         private System.Windows.Forms.Label label2; //通过它实现向远程主机提出TCP连接申请 

         private bool tcpConnect = false; //定义标识符,用以表示TCP连接是否建立

          //连接 

         private void button1_Click(object sender, System.EventArgs e)

         {

              IPAddress ipRemote ;

              try

              {

                   ipRemote = IPAddress.Parse ( textBox1.Text ) ;

              }

              catch //判断给定的IP地址的合法性

              {

                   MessageBox.Show ( "输入的IP地址不合法!" , "错误提示!" ) ;

                   return ;

发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
用户名: 验证码:点击我更换图片
最新评论 更多>>

推荐热点

  • 浅析.NET下XML数据访问新机制
  • asp.net 面试+笔试题目第1/2页
  • C# 邮件地址是否合法的验证
  • asp.net 设置GridView的选中行的实现代码
  • C#高级编程:数据库连接[1]
  • 经典C++程序1
  • IIS 自动回收导致后台定时器失效的问题解决
  • ASP.NET GridView列表代码示例
  • Asp.net MVC源码分析--Action Filter的链式调用
网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
Copyright © 2008-2015 计算机技术学习交流网. 版权所有

豫ICP备11007008号-1