Recent

Author Topic: Indy, Lazarus and Raspberry Pi  (Read 9753 times)

CCostelloe

  • Newbie
  • Posts: 2
Indy, Lazarus and Raspberry Pi
« on: January 29, 2013, 02:03:00 am »
Hi.

I successfully installed FPC 2.6.0, Lazarus 0.9.30.4-1.1 and Indy 10 (the current development snapshot) on a raspberry pi updated and upgraded, a model B with 512MB ram, the only tweak needed was to reduce the GPU memory to 32MB using the memory_split option in raspi-config (I can post my notes on this if anyone is interested).

Anyway, the problem I have is binding to a server socket - in my case, I want to use a HTTP server, Indy's TIdHttpServer, ultimately to act as an X10 controller.  The problem is that when a minimal program using TIdHttpServer tries to bind to port 80, I get "Socket Error #13: Access denied", followed by "Could not bind socket.  Address and port are already in use", but I could not find anything already bound to port 80.

There are a couple of documented issues on Indy server problems (in http://wiki.lazarus.freepascal.org/Indy_with_Lazarus) in a non-Pi environment, which arose with me on an identical setup (with the same code) on a desktop (Centos 6.3 with the latest stable FPC and Lazarus) but applying the fixes on a Pi does not resolve the problem (on the Centos, I also opened port 80 on its firewall and ran Lazarus as root).  The fixes I applied are:

(1) Lazarus Main menu -> Project -> Compiler Options -> Other Page , add the "-dUseCThreads" parameter.
(2) Force the IdTCPServer to work in Id_IPV4 mode.
procedure TForm1.FormActivate(Sender: TObject);
var
  Binding: TIdSocketHandle;
begin
  //uses idGlobal
  //explicitally adding a Binding object prevents TIdTCPServer
  //from creating its own default IPv4 and IPv6 Binding objects
  //on the same listening IP/Port pair...
  Binding := IdTCPServer1.Bindings.Add;
  Binding.IPVersion := Id_IPv4; //optional: forces the Binding to work in Id_IPV4 mode.
  Binding.IP := '127.0.0.1';
  Binding.Port := 6501; //customization
  IdTCPServer1.Active := True; 
end;

I don't know where to go next.  I don't think the Raspberry Pi has a firewall, and am not aware of a restriction on non-root users (the "Pi" user) not being able to open a server socket, but I may well be wrong.  It may be an issue specific to Raspberry Pi, but I thought I should ask here first.  Does anyone have any ideas? 

Thanks,

Ciaran

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12655
  • FPC developer.
Re: Indy, Lazarus and Raspberry Pi
« Reply #1 on: January 29, 2013, 10:13:44 am »
That's pretty normal on *nix. You need to be root to bind to sockets under 1024.

Just run it with sudo

CCostelloe

  • Newbie
  • Posts: 2
Re: Indy, Lazarus and Raspberry Pi
« Reply #2 on: January 29, 2013, 06:36:55 pm »
Hi Marcov, thanks - never realised that.

Just run it with sudo

I will run Lazarus as root via "sudo startlazarus", reinstall Indy then see if my program runs as root when debugging in the IDE.

Thanks

Ciaran

pfetrial

  • Newbie
  • Posts: 1
Re: Indy, Lazarus and Raspberry Pi
« Reply #3 on: February 21, 2013, 03:07:38 pm »
Hi
I'm newbee and I'm trying to install th Indy components on a raspberry. I have the same version as Ccostelloe but I didn't succeed. Ccostelloe , can you please send me your port notes ? thanks my email is:
pfrey2013@yahoo.fr
Thanks a lot

soitjes

  • Newbie
  • Posts: 6
Re: Indy, Lazarus and Raspberry Pi
« Reply #4 on: May 06, 2013, 01:06:45 pm »
Hello Ciaran,

As I'm working on a similar project (see http://www.digitalhomeserver.net/freepascal-on-the-raspberry/) I would be interested to receive your notes as well.

Thanks in advance,

Soitjes.

 

TinyPortal © 2005-2018