WINCE / fphttpserver "Listening on port #1 failed, error: 10022" lazarus / 35-Windows CE ---------------------------------------------------------------------- sanmiolade · 2013-09-16 11:31 Hello All,  These are my problems....I am trying to build a Embedded WebServer for my WINCE Device so  my users can change the device settings via a browser.  I built a Simple WebServer, it works on my Windows Dev Computer  but when I move the same code to my WINCE it gives the "Listening on port #1 failed, error: 10022" Please I need a Solution *** MY CODE IS BELOW **** unit Unit1; {$mode objfpc}{$H+} interface uses   Classes, SysUtils,EmbeddedWebServerClass, FileUtil, Forms,LResources, Controls, Graphics, Dialogs, StdCtrls,fpwebfile,fphttpserver; type   { TForm1 }   TForm1 = class(TForm)     Button1: TButton;     Button2: TButton;     Memo1: TMemo;     procedure Button1Click(Sender: TObject);     procedure Button2Click(Sender: TObject);     procedure FormCreate(Sender: TObject);   private     { private declarations }   public     { public declarations }     procedure HandleWebServerRequest(Sender: TObject; var ARequest: TFPHTTPConnectionRequest; var AResponse: TFPHTTPConnectionResponse);   end; var   Form1: TForm1;   myWebServer :EmbeddedWebServer;   FServer : TFPHTTPServer; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormCreate(Sender: TObject); begin     self.Position:= poDesktopCenter; end; procedure TForm1.Button1Click(Sender: TObject); begin     Memo1.Lines.Add('Starting server');     FServer:=TFPHTTPServer.Create(self);     FServer.Port:=8081;     FServer.OnRequest:=@HandleWebServerRequest;     Memo1.Lines.Add('Done Starting server'); end; procedure TForm1.Button2Click(Sender: TObject); begin     Memo1.Lines.Add('Starting Active '+ inttostr(FServer.Port));   FServer.Active := true;; end; procedure TForm1.HandleWebServerRequest(Sender: TObject; var ARequest: TFPHTTPConnectionRequest; var AResponse: TFPHTTPConnectionResponse); begin       memo1.Lines.add(ARequest.URL); end; end. ---------------------------------------------------------------------- white_zombie · 2013-09-16 15:46 Hi, I suffered this error and your post remember me that I should open a bug report about it. The problem is inside TFPCustomHttpServer, the function "listen" is called twice and this produced an error in Wince but not on Windows and Linux. To be precise, the procedure "StartServerSocket" (see below) call FServer.Listen and inside procedure FServer.StartAccepting is called again. Code: [Select]procedure TFPCustomHttpServer.StartServerSocket; begin   FServer.Bind;   FServer.Listen;   FServer.StartAccepting; end; So, you need to modify the class TFPCustomHttpServer by yourself or wait for this to be resolved by the FPC team. Best Regards. ---------------------------------------------------------------------- sanmiolade · 2013-09-16 17:38 So kindly tell me what EXACTLY I am supposed to do . Will I comment Code ??....if so which Code do I comment ?? Thanks ---------------------------------------------------------------------- sanmiolade · 2013-09-17 04:14 Thanks Guys it WORKED What I did was to Comment out the procedure TFPCustomHttpServer.CreateServerSocket; begin   FServer.Bind;  // FServer.Listen;  <---- COMMENT THIS OUT   FServer.StartAccepting; end;