Ejemplo n.º 1
0
 /// <summary>
 /// 断开服务端监听
 /// </summary>
 private void CloseTCPServer()
 {
     try
     {
         if (_devSerTCP != null)
         {
             _devSerTCP.OnConed  -= new CServerTCP.EventOnConHander(OnTcpStatus);
             _devSerTCP.OnRecved -= new CServerTCP.EventOnRecvHandler(OnTcpRecv);
             _devSerTCP.close();
             _devSerTCP = null;
             SerLog.Log("停止测试TCP服务器监听:端口" + "[" + tcpPort.ToString() + "]", udcRunLog.ELog.Action);
         }
     }
     catch (Exception ex)
     {
         SerLog.Log(ex.ToString(), udcRunLog.ELog.Err);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 关闭监听
 /// </summary>
 public void Close()
 {
     try
     {
         if (serTcp != null)
         {
             serTcp.OnConed  -= new CServerTCP.EventOnConHander(OnTcpStatus);
             serTcp.OnRecved -= new CServerTCP.EventOnRecvHandler(OnTcpRecv);
             serTcp.close();
             serTcp = null;
             OnLogArgs.OnEvented(new CLogArgs(idNo, name, "停止TCP服务器监听:端口" + "[" + tcpPort.ToString() + "]", (int)EResult.Context));
         }
     }
     catch (Exception ex)
     {
         OnLogArgs.OnEvented(new CLogArgs(idNo, name, ex.ToString(), (int)EResult.Error));
     }
 }