|XP is just a number|
Adding simple HTTP controls to existing codeby brachism (Novice)
|on Jul 05, 2021 at 10:29 UTC||Need Help??|
brachism has asked for the wisdom of the Perl Monks concerning the following question:
Probably simple, but I have just started dabbling in Perl. Working on a personal project for the home, I am trying to find a simple, quick, and lightweight method of integrating HTTP input into one of my projects. Most of my similar efforts have utilized NodeMCU’s. Years of using these seem to be clouding my judgement for an effective solution in Perl, a language I am learning.
My existing host’s core code is essentially an endless loop managing a series of host events. The client should be able to send occasional requests to either ‘set something’ or ‘inquire about something.’ The host responses in simple text, either 'ERR', 'OK' or with a short string. The reply to the client will be almost immediate, as the requests just set or return variables. Growing up with dial-up modems, my commands are AT-styled.
For example, to start execution, the follow client request results in $runflag=1
I’ve looked at a few packages, such as HTTP::Server::Simple::CGI. While trying to incorporate the associated examples into my code, all block my main program while waiting for a client. The solution I need, is one where I can frequently poll for a client request. My main loop fire about 5 times a second.Other notes:
- Single client, via HTTP (no SSL), on local network, no authentication
- Client send a command and wait for a response. E.g. http://ava/cmd=ATEP# (0=pause,1=un-pause)
- Host returns a simple text reply “OK”, “ERR”, or a short line of text
- Once reply sent, communication is done; until if/when client send another request
- Response timing is not critical (as in seconds, not milliseconds)
Any suggestions? Thanks in advance.