C#:一个增强的TcpListener(一)构造函数

[csharp]  view plain  copy
  1. /* ---------------------------------------------------------- 
  2. 文件名称:TcpListenerPlus.cs 
  3.  
  4. 作者:秦建辉 
  5.  
  6. MSN:splashcn@msn.com 
  7. QQ:36748897 
  8.  
  9. 博客:http://blog.csdn.net/jhqin 
  10.  
  11. 开发环境: 
  12.     Visual Studio V2010 
  13.     .NET Framework 4 Client Profile 
  14.  
  15. 版本历史: 
  16.     V1.0    2012年04月25日 
  17.             实现线程池通信 
  18.   
  19. 参考资料: 
  20.     http://www.switchonthecode.com/tutorials/csharp-tutorial-simple-threaded-tcp-server 
  21. ------------------------------------------------------------ */  
  22. using System;  
  23. using System.Net;  
  24. using System.Net.Sockets;  
  25. using System.Threading;  
  26.   
  27. namespace Splash.Net.Sockets  
  28. {  
  29.     public partial class TcpListenerPlus : TcpListener  
  30.     {  
  31.         /// <summary>  
  32.         /// 构造函数  
  33.         /// </summary>  
  34.         /// <param name="localEP">本地终结点</param>  
  35.         public TcpListenerPlus(IPEndPoint localEP) : base(localEP)  
  36.         {   // 启动独立的侦听线程  
  37.             Thread ListenThread = new Thread(new ThreadStart(ListenThreadAction));  
  38.             ListenThread.Start();  
  39.         }  
  40.   
  41.         /// <summary>  
  42.         /// 构造函数  
  43.         /// </summary>  
  44.         /// <param name="localaddr">本地IP地址</param>  
  45.         /// <param name="port">侦听端口</param>  
  46.         public TcpListenerPlus(IPAddress localaddr, Int32 port) : base(localaddr, port)  
  47.         {   // 启动独立的侦听线程  
  48.             Thread ListenThread = new Thread(new ThreadStart(ListenThreadAction));  
  49.             ListenThread.Start();  
  50.         }  
  51.   
  52.         /// <summary>  
  53.         /// 析构函数  
  54.         /// </summary>  
  55.         ~TcpListenerPlus()  
  56.         {  
  57.             Stop();  
  58.         }          
  59.     }  
  60. }  
  61. 原文转自“http://blog.csdn.net/jhqin/article/details/7552832
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值