TIdTCPClient 做客户端,正常通信一段时间之后Raised exception class EIdSocketError with message 'Socket Error # 0
'. Process stopped. Use Step or Run to continue.    奇怪的是报这个异常之后,GetLastError竟返回0.

解决方案 »

  1.   

    cgfhz,你所谓的长连接是不是指WAN连接,短连接是不是指LAN连接?如果是,我现在是短连接,并且已有心跳处理
      

  2.   

    dropme,不是这样的,我只是想弄清楚indy在什么情况下会报这个异常
      

  3.   

     while (not Terminated) and (TcpClient.Connected) do
        begin
            try
                TcpClient.ReadBuffer(Cmd, Sizeof(Cmd));  // TcpClient: TIdTCPClient; // TCP客户端组件
                pub_WatchCount := 0;
               
                Synchronize(HandleInput); // 同步过程
            except
                on E: Exception do
                begin
                    if pos('Socket Error # 0',E.Message)>0 then
                    begin
                        CloseConn;
                    end;          
                end;
            end;
        end;
      

  4.   

    #0错误一般是SOCKET断开连接了,需要有重连机制。