Recent

Author Topic: Socket components for Raspberry Pi  (Read 5267 times)

ertank

  • Full Member
  • ***
  • Posts: 244
Socket components for Raspberry Pi
« 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

taazz

  • Hero Member
  • *****
  • Posts: 5363
Re: Socket components for Raspberry Pi
« Reply #1 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.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Thaddy

  • Hero Member
  • *****
  • Posts: 9189
Re: Socket components for Raspberry Pi
« Reply #2 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.
« Last Edit: December 26, 2017, 09:31:28 am by Thaddy »
also related to equus asinus.

ttomas

  • Full Member
  • ***
  • Posts: 181
Re: Socket components for Raspberry Pi
« Reply #3 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.

Thaddy

  • Hero Member
  • *****
  • Posts: 9189
Re: Socket components for Raspberry Pi
« Reply #4 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.
also related to equus asinus.

ertank

  • Full Member
  • ***
  • Posts: 244
Re: Socket components for Raspberry Pi
« Reply #5 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.

ertank

  • Full Member
  • ***
  • Posts: 244
Re: Socket components for Raspberry Pi
« Reply #6 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.

ertank

  • Full Member
  • ***
  • Posts: 244
Re: Socket components for Raspberry Pi
« Reply #7 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.

taazz

  • Hero Member
  • *****
  • Posts: 5363
Re: Socket components for Raspberry Pi
« Reply #8 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).
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

ertank

  • Full Member
  • ***
  • Posts: 244
Re: Socket components for Raspberry Pi
« Reply #9 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.