procedure TSocketClient.ClientSocketError(Sender: TObject; Socket: TCustomWinSocket; ErrorEvent: TErrorEvent; var ErrorCode: Integer); begin Case ErrorCode of 10053: begin ErrorCode:=0; end; 10054: begin ErrorCode:=0; end; 10060: begin ErrorCode:=0; end else ErrorCode:=0; end;end;
另一个方法 1.使用完就Disconnect,就没有信息弹出. try IdTCPClient1.Connect; try try // Do your communications here finally IdTCPClient1.Disconnect; end; except on E: EIdException do begin ShowMessage('An network error occurred during communication: ' + E.Message); end; on E: Exception do begin ShowMessage('An unknown error occurred during communication: ' + E.Message); end; end; except on E: EIdException do begin ShowMessage('An network error occurred while trying to connect: ' + E.Message); end; on E: Exception do begin ShowMessage('An unknown error occurred while trying to connect: ' + E.Message); end; end;
Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
var ErrorCode: Integer);
begin
Case ErrorCode of
10053:
begin
ErrorCode:=0;
end;
10054:
begin
ErrorCode:=0;
end;
10060:
begin
ErrorCode:=0;
end
else
ErrorCode:=0;
end;end;
1.使用完就Disconnect,就没有信息弹出.
try
IdTCPClient1.Connect; try
try
// Do your communications here
finally IdTCPClient1.Disconnect; end;
except
on E: EIdException do begin
ShowMessage('An network error occurred during communication: '
+ E.Message);
end;
on E: Exception do begin
ShowMessage('An unknown error occurred during communication: '
+ E.Message);
end;
end;
except
on E: EIdException do begin
ShowMessage('An network error occurred while trying to connect: '
+ E.Message);
end;
on E: Exception do begin
ShowMessage('An unknown error occurred while trying to connect: '
+ E.Message);
end;
end;