加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Delphi Indy:连接正常关闭

发布时间:2020-12-15 03:49:56 所属栏目:大数据 来源:网络整理
导读:使用D7 Indy 10最新版本. 我的代码使用TIdSMTP发送电子邮件. 我一直在某些最终用户处“正常关闭连接”,并且永远不会发送电子邮件. 代码如下: try~~~~~~~~_idSMTP := TIdSmtp.Create;with _idSMTP dobegin Host := 'myhost'; Connect; try Send(_EmailMsg);
使用D7 Indy 10最新版本.

我的代码使用TIdSMTP发送电子邮件.
我一直在某些最终用户处“正常关闭连接”,并且永远不会发送电子邮件.

代码如下:

try
~~~~
~~~~
_idSMTP := TIdSmtp.Create;
with _idSMTP do
begin
  Host := 'myhost';
  Connect;
  try
    Send(_EmailMsg);
    Result := True;
  except
    on E: Exception do
    begin
      MsgDlgErr(Self.Handle,E.Message)
    end
  end;
end;
finally
 _idSMTP.Disconnect;
 _idSMTP.Free;
end;

任何建议?

解决方法

在 http://www.swissdelphicenter.ch/en/showarticle.php?id=1阅读所有相关内容

EIdConnClosedGracefully is an
exception signaling that the
connection has been closed by the
other side intentionally. This is not
the same as a broken connection which
would cause a connection reset error.
If the other side has closed the
connection and the socket is read or
written to,EIdConnClosedGracefully
will be raised by Indy. This is
similar to attempting to read or write
to a file that has been closed without
your knowledge.

In some cases this is a true exception and your code needs to handle it. In other cases (typically servers) this is a normal part of the functioning of the protocol and Indy handles this exception for you. Even though Indy catches it,when running in the IDE the debugger will be triggered first. You can simply press F9 to continue and Indy will handle the exception,but the constant stopping during debugging can be quite annoying. In the cases where Indy catches the exception,your users will never see an exception in your program unless it is run from the IDE.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读