【发布时间】:2009-06-19 08:56:07
【问题描述】:
第一个问题:
以下例程是 Indy 9 IdTcpServer.OnExecute 例程的正确实现吗?
procedure TMyConnServer.ServerExecute(AContext: TIdPeerThread);
var
buffSize: integer;
str: string;
begin
AContext.Connection.ReadFromStack(True, 600, False);
buffSize := AContext.Connection.InputBuffer.Size;
if (buffSize > 0) then
{ Extract input buffer as string }
str := AContext.Connection.ReadString(buffSize);
{ Notify connection object of received data }
if (AContext.Data <> nil) then
begin
TConnectionHandler(AContext.Data).Read(str);
end;
end;
end;
第二个(实际上更重要的)问题:
现在偶尔会出现访问冲突(从地址 000000 读取)。显然在行:
AContext.Connection.ReadFromStack(True, 600, False);
但检查 AContext / Connection / InputBuffer / IOHandler = nil BEFORE 是否为假。 调用之后(以及引发异常之后)IOHandler 为 nil。
我们使用的是 RAD Studio / Delphi 2007。
【问题讨论】:
标签: delphi tcp indy access-violation