Recent

Author Topic: Server side pascal - accepting input and producing output  (Read 3607 times)

ajavdk

  • Newbie
  • Posts: 3
Server side pascal - accepting input and producing output
« on: June 30, 2018, 07:59:49 pm »
Hello,

I have a pascal program that I would like to be able to run on a server. I was hoping there is a way of passing the pascal program some kind of input (even if it is just interpreted as a string), and then somehow 'returning' to the server an output (again, even if the output is just a string). Can someone point me towards resources regarding doing this? I'm not sure what to search in the forums.

-Alex

Handoko

  • Hero Member
  • *****
  • Posts: 5458
  • My goal: build my own game engine using Lazarus
Re: Server side pascal - accepting input and producing output
« Reply #1 on: June 30, 2018, 08:12:58 pm »
I read @rvk posts and then I was able to understand how to write program for server and client to communicate, he explained it well. Maybe this is what you're looking for:
https://forum.lazarus.freepascal.org/index.php/topic,38622
« Last Edit: June 30, 2018, 08:14:58 pm by Handoko »

bee

  • Sr. Member
  • ****
  • Posts: 393
Re: Server side pascal - accepting input and producing output
« Reply #2 on: July 01, 2018, 03:04:22 am »
If what you meant is a web application then I suggest you to try WebCRT unit that I made to help Pascal newbies creating server side web applications (as CGI apps) using Free Pascal.

The WebCRT announcement is here: https://forum.lazarus.freepascal.org/index.php/topic,33946.msg221205.html#msg221205

The GitHub repository is here: https://github.com/pakLebah/webCRT

Happy coding! :)
-Bee-

A long time pascal lover.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8819
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Server side pascal - accepting input and producing output
« Reply #3 on: July 02, 2018, 04:59:08 am »
While other answers assume you want your Pascal program to run as a server by itself (which is perfectly possible), I assume you just want to call it from an existing web server application.
I was hoping there is a way of passing the pascal program some kind of input (even if it is just interpreted as a string)
http://wiki.lazarus.freepascal.org/Command_line_parameters_and_environment_variables
https://www.freepascal.org/docs-html/rtl/getopts/index.html
and then somehow 'returning' to the server an output (again, even if the output is just a string).
Depending on how the existing web server application executes your Pascal program's binary, there could be several ways. The better one is to use pipes, so your existing web application should read stdout (and/or stderr if you want) from your Pascal program. Otherwise any shared resource mechanism (files, sockets, even databases) is fine.

mangakissa

  • Hero Member
  • *****
  • Posts: 1131
Re: Server side pascal - accepting input and producing output
« Reply #4 on: July 02, 2018, 08:54:21 am »
Look at the middleware tools like Mormot and TIOPF.
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

sash

  • Sr. Member
  • ****
  • Posts: 366
Re: Server side pascal - accepting input and producing output
« Reply #5 on: July 03, 2018, 12:26:54 am »
My bet: you need console program launched with telnet/ssh (?)
Lazarus 2.0.10 FPC 3.2.0 x86_64-linux-gtk2 @ Ubuntu 20.04 XFCE

 

TinyPortal © 2005-2018