- /* ----------------------------------------------------------
- 文件名称:TcpListenerPlus.cs
- 作者:秦建辉
- MSN:splashcn@msn.com
- QQ:36748897
- 博客:http://blog.csdn.net/jhqin
- 开发环境:
- Visual Studio V2010
- .NET Framework 4 Client Profile
- 版本历史:
- V1.0 2012年04月25日
- 实现线程池通信
- 参考资料:
- http://www.switchonthecode.com/tutorials/csharp-tutorial-simple-threaded-tcp-server
- ------------------------------------------------------------ */
- using System;
- using System.Net;
- using System.Net.Sockets;
- using System.Threading;
- namespace Splash.Net.Sockets
- {
- public partial class TcpListenerPlus : TcpListener
- {
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="localEP">本地终结点</param>
- public TcpListenerPlus(IPEndPoint localEP) : base(localEP)
- { // 启动独立的侦听线程
- Thread ListenThread = new Thread(new ThreadStart(ListenThreadAction));
- ListenThread.Start();
- }
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="localaddr">本地IP地址</param>
- /// <param name="port">侦听端口</param>
- public TcpListenerPlus(IPAddress localaddr, Int32 port) : base(localaddr, port)
- { // 启动独立的侦听线程
- Thread ListenThread = new Thread(new ThreadStart(ListenThreadAction));
- ListenThread.Start();
- }
- /// <summary>
- /// 析构函数
- /// </summary>
- ~TcpListenerPlus()
- {
- Stop();
- }
- }
- }
- 原文转自“http://blog.csdn.net/jhqin/article/details/7552832
C#:一个增强的TcpListener(一)构造函数
最新推荐文章于 2023-11-01 23:02:36 发布