Lazarus

Programming => Operating Systems => Other => Topic started by: ertank on December 26, 2017, 07:21:32 am

Title: Socket components for Raspberry Pi
Post by: ertank on December 26, 2017, 07:21:32 am
Hello,

I mostly used databases in Raspberry Pi and sensor readings. Now, there is a project that I need to listen some network port for receiving files and serve a very basic html page in an application.

I cannot use a web server like apache or similar as html pages will be dynamically generated and there will be some database inserts depending on incoming url.

I wonder what most people prefer when it comes to sockets in Raspberry Pi.

Thanks & regards,
Ertan
Title: Re: Socket components for Raspberry Pi
Post by: taazz on December 26, 2017, 07:42:52 am
Hello,

I mostly used databases in Raspberry Pi and sensor readings. Now, there is a project that I need to listen some network port for receiving files and serve a very basic html page in an application.

I cannot use a web server like apache or similar as html pages will be dynamically generated and there will be some database inserts depending on incoming url.
there are a number of protocols and solution for dynamic HTML resutls.(FAST)CGI, ISAPI are the main protocols and there are scripting languages on top of them to create the html like PHP, ASP.NET, DelphiWebScript(for a pascal based script), perl and others.
I wonder what most people prefer when it comes to sockets in Raspberry Pi.

Thanks & regards,
Ertan
Personally I use the INDY library for most of my Networking needs. There are others that are stable but non with the plethora of servers and clients that the indy library has.
Title: Re: Socket components for Raspberry Pi
Post by: Thaddy on December 26, 2017, 09:02:58 am
For Raspberry Pi zero, 1 and 3:
I don't use components for such things, but classes. I prefer Synapse 4.1 because of its speed and stability. It also has a much smaller footprint than Indy, which is good on e.g. a pi zero W or pi 1.
Though I tend to use fcl-web more and more, because it is getting better and better, also supports secure connecions by now and is in the standard fpc distribution. It is also lightweight and stable.
Indy is also a good solution, but rather heavy and can be much slower than synapse. Furthermore I experienced so many difficulties with Indy on Delphi in the past that I still hate to use or recommend it.
But I have heard that things are much better now,

Note fcl-web is a perfect lightweight server solution for creating dynamic pages in all pure pascal. To create content, use e.g. the fptemplate features and maybe an sqldb,+ BufDataset  but  also have a look at the recent pas2js: already very, very usable and also works with node.js.

fcl-web:
Code: Text  [Select][+][-]
  1. pi@thaddy_rpi3_1:~/fpc311/packages/fcl-web/examples/httpserver $ ls -l
  2. total 424
  3. -rwxr-xr-x 1 pi pi 318208 Dec 26 09:20 simplehttpserver

So a simple server is just 300K on the Raspberry Pi.
Title: Re: Socket components for Raspberry Pi
Post by: ttomas on December 26, 2017, 09:45:07 am
Invest some time in mORMot.
Futures: http server, REST, JSON, SQLite3, ORM, WebSocket, mustache, external DB,...
For all futures you need fpc/lazarus trunk/trunk. You cen use fpcupdeluxe to install trunk/trunk or NewPascal version.
Title: Re: Socket components for Raspberry Pi
Post by: Thaddy on December 26, 2017, 09:59:45 am
Invest some time in mORMot.
Futures: http server, REST, JSON, SQLite3, ORM, WebSocket, mustache, external DB,...
For all futures you need fpc/lazarus trunk/trunk. You cen use fpcupdeluxe to install trunk/trunk or NewPascal version.

That's - huge - overkill for the purpose of the question. But mOrMot is good.. Just not here.

Much simpler to use a fptemplated page, listen to the socket that receives data (a fphttpclient or serial component) and serve the generated page with a fphttpserver.
The whole thing can be done in 600Kb on a raspberry pi.
Title: Re: Socket components for Raspberry Pi
Post by: ertank on December 26, 2017, 11:30:27 am
Personally I use the INDY library for most of my Networking needs. There are others that are stable but non with the plethora of servers and clients that the indy library has.
I did not try if Indy working on Raspberry Pi before. I am using recent Indy 10 version on PC applications. So far happy with it.

What version are you using?
Do you get the sources from SVN?

Thanks.
Title: Re: Socket components for Raspberry Pi
Post by: ertank on December 26, 2017, 11:56:45 am
Note fcl-web is a perfect lightweight server solution for creating dynamic pages in all pure pascal. To create content, use e.g. the fptemplate features and maybe an sqldb,+ BufDataset  but  also have a look at the recent pas2js: already very, very usable and also works with node.js.

fcl-web:
Code: Text  [Select][+][-]
  1. pi@thaddy_rpi3_1:~/fpc311/packages/fcl-web/examples/httpserver $ ls -l
  2. total 424
  3. -rwxr-xr-x 1 pi pi 318208 Dec 26 09:20 simplehttpserver

So a simple server is just 300K on the Raspberry Pi.
Thank you Thaddy. I will definitely check fcl-web. It is just I am used to Indy on PC side, and feel comfortable using it. Therefore, I will first try Indy next fcl-web.

I will make my decision after testing both.
Title: Re: Socket components for Raspberry Pi
Post by: ertank on December 26, 2017, 11:59:41 am
Invest some time in mORMot.
Futures: http server, REST, JSON, SQLite3, ORM, WebSocket, mustache, external DB,...
For all futures you need fpc/lazarus trunk/trunk. You cen use fpcupdeluxe to install trunk/trunk or NewPascal version.
I have other applications developed with mORMot. Some running on Raspberry Pi. However, I am still a learner for this framework and ORM generally. For this project however, I will most likely use some other sockets class/component.

Thanks.
Title: Re: Socket components for Raspberry Pi
Post by: taazz on December 26, 2017, 05:37:52 pm
Personally I use the INDY library for most of my Networking needs. There are others that are stable but non with the plethora of servers and clients that the indy library has.
I did not try if Indy working on Raspberry Pi before. I am using recent Indy 10 version on PC applications. So far happy with it.

What version are you using?
Do you get the sources from SVN?

Thanks.
raspeberryPI comes with a linux OS and linux is supported with Indy. personally I'm using an old version (10.5.8.5124) on lazarus 1.4.4 for both windows and linux with no known problems so far but my usage is a bit light mostly for fun the last years (after we moved to C# at work).
Title: Re: Socket components for Raspberry Pi
Post by: ertank on December 27, 2017, 07:54:51 pm
Note fcl-web is a perfect lightweight server solution for creating dynamic pages in all pure pascal. To create content, use e.g. the fptemplate features and maybe an sqldb,+ BufDataset  but  also have a look at the recent pas2js: already very, very usable and also works with node.js.
Hello Thaddy,

I need to do some proprietary TCP communication together with dynamic http page serving. If you know, would you tell if fcl-web also provides a TCP server capability along with HTTP serving?

Thanks.
TinyPortal © 2005-2018