Hello,

I updated the fcl-net and fcl-web of my Free Pascal copy, but when I try to
terminate my app via request, it return same error reported in this topic.

My code is:


   1. program project1;
   2.
   3. {$mode objfpc}{$H+}
   4.
   5. uses
   6.   heaptrc, sysutils, HttpDefs, CustWeb, CustHTTPApp, FPHTTPServer;
   7.
   8. type
   9.
   10.   { TMyHttpApplication }
   11.
   12.   TMyHttpApplication = class(TCustomHTTPApplication)
   13.   protected
   14.     function InitializeWebHandler: TWebHandler; override;
   15.   end;
   16.
   17.   { TMyEmbeddedHttpServer }
   18.
   19.   TMyEmbeddedHttpServer = class(TEmbeddedHttpServer)
   20.   protected
   21.     function CreateRequest: TFPHTTPConnectionRequest; override;
   22.     function CreateResponse(ARequest: TFPHTTPConnectionRequest):
   23.       TFPHTTPConnectionResponse; override;
   24.   public
   25.     property Active;
   26.   end;
   27.
   28.   { TMyHttpServerHandler }
   29.
   30.   TMyHttpServerHandler = class(TFPHTTPServerHandler)
   31.   protected
   32.     function CreateServer: TEmbeddedHttpServer; override;
   33.   public
   34.     procedure HandleRequest(ARequest: TRequest; AResponse: TResponse)
   ; override;
   35.   end;
   36.
   37.   { TMyHttpApplication }
   38.
   39.   function TMyHttpApplication.InitializeWebHandler: TWebHandler;
   40.   begin
   41.     Result := TMyHttpServerHandler.Create(Self);
   42.   end;
   43.
   44.   { TMyEmbeddedHttpServer }
   45.
   46.   function TMyEmbeddedHttpServer.CreateRequest:
    TFPHTTPConnectionRequest;
   47.   begin
   48.     Result := TFPHTTPConnectionRequest.Create;
   49.   end;
   50.
   51.   function TMyEmbeddedHttpServer.CreateResponse(
   52.     ARequest: TFPHTTPConnectionRequest): TFPHTTPConnectionResponse;
   53.   begin
   54.     Result := TFPHTTPConnectionResponse.Create(ARequest);
   55.   end;
   56.
   57.   { TMyHttpServerHandler }
   58.
   59.   function TMyHttpServerHandler.CreateServer: TEmbeddedHttpServer;
   60.   begin
   61.     Result := TMyEmbeddedHttpServer.Create(Self);
   62.   end;
   63.
   64. var
   65.   App: TMyHttpApplication;
   66.
   67.   procedure TMyHttpServerHandler.HandleRequest(ARequest: TRequest;
   68.     AResponse: TResponse);
   69.   begin
   70.     if not App.Terminated then
   71.       App.Terminate;
   72.   end;
   73.
   74. begin
   75.   App := TMyHttpApplication.Create(nil);
   76.   try
   77.     App.Port := 5445;
   78.     App.Threaded := True;
   79.     App.Initialize;
   80.     App.Run;
   81.     DeleteFile('HEAP.TRC');
   82.     SetHeapTraceOutput('HEAP.TRC');
   83.   finally
   84.     App.Free;
   85.   end;
   86. end.


http://pastebin.com/503S2Nin

The error:

"Could not accept a client connection on socket: -1, error 10004."

Thank you!

-- 
Silvio Clécio
My public projects - github.com/silvioprog
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to