procedure Tfmmain.ClientSocket1Error(Sender: TObject;
Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
var ErrorCode: Integer);
var
x:integer;
begin
x:=errorcode;
errorcode:=0;
self.Bar1.SimpleText:='网络不通,请检查.错误号'+inttostr(x);
messagebeep(0);
self.ClientSocket1.Active:=false;
end;
试试这个,在socket的 onerror事件里