XE8-indy10中关于Connection Closed Gracefully的源码与解读

在XE8中,使用indy10里有关TCP连接的控件时,断开连接有时候会抛出Connection Closed Gracefully的异常,下面我找到了抛出该异常的源码:

procedure TIdIOHandler.RaiseConnClosedGracefully;
begin
  (* ************************************************************* //
  ------ If you receive an exception here, please read. ----------

  If this is a SERVER
  -------------------
  The client has disconnected the socket normally and this exception is used to notify the
  server handling code. This exception is normal and will only happen from within the IDE, not
  while your program is running as an EXE. If you do not want to see this, add this exception
  or EIdSilentException to the IDE options as exceptions not to break on.

  From the IDE just hit F9 again and Indy will catch and handle the exception.

  Please see the FAQ and help file for possible further information.
  The FAQ is at http://www.nevrona.com/Indy/FAQ.html

  If this is a CLIENT
  -------------------
  The server side of this connection has disconnected normaly but your client has attempted
  to read or write to the connection. You should trap this error using a try..except.
  Please see the help file for possible further information.

  // ************************************************************* *)
  raise EIdConnClosedGracefully.Create(RSConnectionClosedGracefully);
end;

中文翻译:

  (* ************************************************************* //
  ------ If you receive an exception here, please read. ----------

  ------ 如果你收到此异常,请阅读下面内容 ----------


  If this is a SERVER

如果是服务器
  -------------------
  The client has disconnected the socket normally and this exception is used to notify the
  server handling code. This exception is normal and will only happen from within the IDE, not
  while your program is running as an EXE. If you do not want to see this, add this exception
  or EIdSilentException to the IDE options as exceptions not to break on.

客户端已经正常关闭该套接字了,这个异常用来提示服务器处理该代码。

这个异常很正常,并且只会在IDE中发生,在可执行文件(EXE)中并不会发生。

如果你不想看到它,可以在IDE选项中设置EIdSilentException这个异常不被打断。



  From the IDE just hit F9 again and Indy will catch and handle the exception.

在IDE中,只要再次按下F9,indy将会捕捉并处理该异常。


  Please see the FAQ and help file for possible further information.
  The FAQ is at http://www.nevrona.com/Indy/FAQ.html
请查看有关的FAQ和帮助文档。

FAQ是http://www.nevrona.com/Indy/FAQ.html


  If this is a CLIENT

如果是客户端
  -------------------
  The server side of this connection has disconnected normaly but your client has attempted
  to read or write to the connection. You should trap this error using a try..except.
  Please see the help file for possible further information.
服务端已经正常关闭连接了,可是客户端却尝试从该连接中读写数据。

你应该用try...except捕捉此错误。

请看有关的帮助文档。

  // ************************************************************* *)

你可能感兴趣的:(Delphi,indy10)