Destroying a form with TIdHTTPServer causes Socket Error # 10038 Socket operation on non-socket

147 Views Asked by At

Destroying a form with TIdHTTPServer causes

EIdSocketError with message 'Socket Error # 10038 Socket operation on non-socket.'

if some HTTP request was already processed.

It makes absolutely no difference whether I create TIdHTTPServer with form as an owner and do not call TIdHTTPServer.Free in form destructor or set owner to nil and call TIdHTTPServer.Free in form destructor.

How to make TIdHTTPServer shut down gracefully without causing any debugger exceptions?

I found out only one way to eliminate this error:

destructor THFServer.Destroy();
begin
  _server.Active := False;
  Sleep(5000);
  inherited;
end;

but I think it's not the right way.

0

There are 0 best solutions below