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捕捉此错误。

请看有关的帮助文档。

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值