当ServerSocket发生onClientError事件的时候,如何断开服务器和Socket.RemoteHost的连接?
不至于出现什么api错误和什么10305之类的错误代码?意思是出现error的时候如何断开与出现错误机器的连接???

解决方案 »

  1.   

    Write an OnError event handler to respond to errors that arise with the socket connection. Set the ErrorCode parameter to 0 if the OnError event handler successfully deals with the error condition, to prevent an ESocketError from being raised.照你的话和帮助来看,你是会出现错误代码,只需要将 ErrorCode 设为0就行了。procedure TForm1.ClientSocket1Error(Sender: TObject;
      Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
      var ErrorCode: Integer);
    begin
      ErrorCode := 0;
      Socket.Close;
    end;
      

  2.   

    ErrorCode:=0;
    Socket.Active:=false;
      

  3.   

    任务完成,将所有的程序如下
     DeleteStudentLoginINRemost(Socket.RemoteHost);//清除数据
       ErrorCode:=0;
       StatusBar1.Panels.Items[0].Text: = "继续....";
       List_info.Items.Add(Socket.RemoteHost+"退出");
       ServerSocket.Close();
       Disconnect1Click(NULL);//断开连接,重新监测
    ---------------------------------------------------------------------------------
    有一个典故:画一个圈1美元,在什么地方画圈9999美元!!散分