Skip to content

Instantly share code, notes, and snippets.

@CelliesProjects
Created September 22, 2017 14:03
Show Gist options
  • Save CelliesProjects/d8f249312f3ef50c21d215c87590eb1c to your computer and use it in GitHub Desktop.
Save CelliesProjects/d8f249312f3ef50c21d215c87590eb1c to your computer and use it in GitHub Desktop.
Pseudo code to show how to allocate an instance of a server on ESP8266 or ESP32.
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
ESP8266WebServer *server;
void setup(){
//This allocates a new instance of ESP8266WebServer
server=new(ESP8266WebServer);
if(server==NULL) //Insert code to handle allocation-error
//Setup your server here
server->begin();
}
servernolongerneeded(){
//This destroys the allocated server and frees up all the resources it used
delete(server);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment