in reply to Re^3: Adding simple HTTP controls to existing code
in thread Adding simple HTTP controls to existing code
Sorry, for possibly being too verbose in this thread. First, thanks for replying.
I have a Perl program. The 1,300-ish line program runs on a headless box. It works great. It blissfully runs along managing a series of tasks. It also has absolutely nothing to do with the network.
I simply need that program to also listen on the network for very infrequent simple HTTP requests. Those requests, if valid, simply tweak parameters in that Perl program altering it functionality. The client, in this case is not Perl. The client is just some simple web browser passing a parameter within the URL. No parallel, one host, and one client.
The core of my program is basically an endless loop, that fires roughly every 200ms. If there is something for it to do, it does it. I just want to add into that loop, a listener for requests. If we got a request in the last 200-ish ms, process it, and continue on. If not, continue on.
The solutions I found online and tried, all so far seem to be blocking. In other words, when I check for a request, it just listens and waits forever. Some did have timeout features, but waiting and timeout out repeatedly for infrequent traffic just seems wasteful.
I just figured this would be easier. On a NodeMCU ESP8266 this is just a few lines of code.
#include <ESP8266WiFi.h> Void loop() { … if (WiFi.status() != WL_CONNECTED) ConnectWifi(); client = server.available(); if (client) { // HAVE A REQUEST while (!client.available()) delay(10); String request = client.readStringUntil('\r'); client.flush(); // PROCESS REQUEST } // CONTINUE DOING ALL THE NON-NETWORK STUFF sleep(50); … }
I will investigate Corion suggestions. This is basic stuff, so I'm sure I’ll figure out something.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: Adding simple HTTP controls to existing code
by tybalt89 (Monsignor) on Jul 05, 2021 at 17:46 UTC | |
by brachism (Novice) on Jul 05, 2021 at 18:31 UTC | |
Re^5: Adding simple HTTP controls to existing code
by tybalt89 (Monsignor) on Jul 05, 2021 at 21:38 UTC | |
Re^5: Adding simple HTTP controls to existing code
by huck (Prior) on Jul 05, 2021 at 18:33 UTC | |
by brachism (Novice) on Jul 05, 2021 at 19:25 UTC | |
by huck (Prior) on Jul 05, 2021 at 20:00 UTC | |
Re^5: Adding simple HTTP controls to existing code
by karlgoethebier (Abbot) on Jul 08, 2021 at 08:20 UTC |