【发布时间】:2014-07-27 18:51:36
【问题描述】:
是否可以让我的TCPServer.OnExecute 事件的行为方式与HTTPServer.OnCommandGet 的行为方式相同:
procedure TMainForm.HttpServerCommandGet(AContext: TIdContext;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
begin
AResponseInfo.ResponseNo := 200;
AResponseInfo.ContentType := 'text/plain';
AResponseInfo.ContentText := 'Hello';
end;
我试过这个:
procedure TMainForm.TCPServerExecute(AContext: TIdContext);
begin
AContext.Connection.IOHandler.WriteLn('Hello');
end;
但它会无限次向浏览器发送“Hello”,直到我使服务器处于非活动状态。
【问题讨论】: