一.TcpSvr的使用方法
A.测试程序:
using System;
using Ibms.Net.TcpCSFramework;
using System.Collections;
using System.Net.Sockets;
namespace Ibms.Test
{
 /// 
 /// 测试TcpSvr的类
 /// 
 public class TestTcpSvr
 {
  
  public TestTcpSvr()
  {
   
  }
  
  public static  void Main()
  {
   try
   {
    Console.WriteLine("Begin to Test TcpSvr class...");
    TestTcpSvr tts = new TestTcpSvr();
    //TcpSvr svr = new TcpSvr(9050,4);//默认使用Encoding.Default编码方式
    TcpSvr svr = new TcpSvr(9050,4,new Coder(Coder.EncodingMothord.UTF8));
    svr.Resovlver = new DatagramResolver("##");
    //定义服务器的4个事件
    //服务器满
    svr.ServerFull += new NetEvent(tts.ServerFull);
    //新客户端连接
    svr.ClientConn += new NetEvent(tts.ClientConn);
    //客户端关闭
    svr.ClientClose += new NetEvent(tts.ClientClose);
    //接收到数据
    svr.RecvData += new NetEvent(tts.RecvData);
    
    //命令控制循环
    while(true)
    {
     Console.Write(">");
     string cmd=Console.ReadLine();
     //退出测试程序
     if(cmd.ToLower() == "exit")
     {
      break;
     }
     //停止服务器程序
     if(cmd.ToLower() == "stop")
     {
      svr.Stop();
      Console.WriteLine("Server is Stop.");
      continue;
     }
     //运行服务器程序