diff --git a/CMakeLists.txt b/CMakeLists.txt
index af21d56c15a0ec2c28d8a8dc95839e5428337beb..2052106ba054768ad31a68c26b7b0568bf360fa0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -53,7 +53,6 @@ option(LWS_STATIC_PIC "Build the static version of the library with position-ind
 #
 # Specific platforms
 #
-option(LWS_WITH_ESP8266 "Build for ESP8266" OFF)
 option(LWS_WITH_ESP32 "Build for ESP32" OFF)
 option(LWS_PLAT_OPTEE "Build for OPTEE" OFF)
 #
@@ -210,23 +209,6 @@ message(STATUS "LWS_WITH_SMTP --> Enabling LWS_WITH_LIBUV")
  set(LWS_WITH_LIBUV 1)
 endif()
 
-if (LWS_WITH_ESP8266)
- set(LWS_WITH_SHARED OFF)
- set(LWS_WITH_SSL OFF)
- set(LWS_WITH_ZLIB OFF)
- set(LWS_WITHOUT_CLIENT ON)
- set(LWS_WITHOUT_TESTAPPS ON)
- set(LWS_WITHOUT_EXTENSIONS ON)
- set(LWS_WITH_PLUGINS OFF)
- set(LWS_WITH_RANGES OFF)
- # this implies no pthreads in the lib
- set(LWS_MAX_SMP 1)
- set(LWS_HAVE_MALLOC 1)
- set(LWS_HAVE_REALLOC 1)
- set(LWS_HAVE_GETIFADDRS 1)
- set(LWS_WITH_ZIP_FOPS 0)
-endif()
-
 if (LWS_WITH_ESP32)
  set(LWS_WITH_SHARED OFF)
  set(LWS_WITH_MBEDTLS ON)
@@ -481,10 +463,6 @@ if ("${LWS_MAX_SMP}" STREQUAL "")
 endif()
 
 
-if (LWS_WITH_ESP8266)
-set(CMAKE_C_FLAGS "-nostdlib ${CMAKE_C_FLAGS}")
-endif()
-
 if (MINGW)
 	set(LWS_MINGW_SUPPORT 1)
 	set(CMAKE_C_FLAGS "-D__USE_MINGW_ANSI_STDIO ${CMAKE_C_FLAGS}")
@@ -808,22 +786,17 @@ if (WIN32)
 		lib/plat/lws-plat-win.c)
 else()
 
-	if (LWS_WITH_ESP8266)
+	if (LWS_PLAT_OPTEE)
 		list(APPEND SOURCES
-			lib/plat/lws-plat-esp8266.c)
+			lib/plat/lws-plat-optee.c)
 	else()
-		if (LWS_PLAT_OPTEE)
+		if (LWS_WITH_ESP32)
 			list(APPEND SOURCES
-				lib/plat/lws-plat-optee.c)
+				lib/plat/lws-plat-esp32.c
+				lib/misc/romfs.c)
 		else()
-			if (LWS_WITH_ESP32)
-				list(APPEND SOURCES
-					lib/plat/lws-plat-esp32.c
-					lib/misc/romfs.c)
-			else()
-				list(APPEND SOURCES
-					lib/plat/lws-plat-unix.c)
-			endif()
+			list(APPEND SOURCES
+				lib/plat/lws-plat-unix.c)
 		endif()
 	endif()
 endif()
@@ -937,7 +910,7 @@ if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_C_COMPILER_ID
     if (LWS_WITH_GCOV)
 	    set (GCOV_FLAGS "-fprofile-arcs -ftest-coverage -O0")
     endif()
-    if ((UNIX OR LWS_WITH_ESP8266) AND NOT LWS_WITH_ESP32)
+    if (UNIX AND NOT LWS_WITH_ESP32)
 	    set(CMAKE_C_FLAGS "-Wall -Wsign-compare -Wignored-qualifiers -Wtype-limits -Wuninitialized -Werror ${VISIBILITY_FLAG} -Wundef ${GCOV_FLAGS} ${CMAKE_C_FLAGS}" )
     else()
 	    set(CMAKE_C_FLAGS "-Wall -Wsign-compare -Wignored-qualifiers -Wtype-limits -Wuninitialized -Werror ${VISIBILITY_FLAG} ${GCOV_FLAGS} ${CMAKE_C_FLAGS}" )
diff --git a/READMEs/README.esp8266.md b/READMEs/README.esp8266.md
deleted file mode 100644
index ffcf7578d04664a9cc0cc043b3d40ebef4bbc81b..0000000000000000000000000000000000000000
--- a/READMEs/README.esp8266.md
+++ /dev/null
@@ -1,34 +0,0 @@
-ESP8266 lws port
-----------------
-
-lws can now work well on the ESP8266.
-
-You should get the ESP8266 Espressif SDK-based project here
-
-https://github.com/lws-team/esplws
-
-which includes lws as an "app" in the build.  The project provides full AP-based setup over the web, and once the device has been configured to associate to a local AP, a separate station vhost with the lws test protocols.
-
-Instructions for building that are here
-
-https://github.com/lws-team/esplws/blob/master/README.md
-
-There are also instructions there for how to remove the test apps from the build and customize your own station content.
-
-
-Information about lws integration on ESP8266
---------------------------------------------
-
-The following existing lws features are used to make a nice integration:
-
- - vhosts: there are separate vhosts for the configuration AP mode and the normal station mode.
-
- - file_ops: the lws file operations are overridden and handled by a ROMFS parser
-
- - mounts: mounts are used to serve files automatically from the ROMFS
-
- - plugins: standalone protocol plugins are included into the build, so there are clean individual implementations for each protocol, while everything is statically linked
-
- - lws stability and security features like bytewise parsers, sophisticated timeouts, http/1.1 keepalive support
-
-
diff --git a/cmake/lws_config.h.in b/cmake/lws_config.h.in
index d6ddd3c5d4d042b60bdc11cca64161a463bdc706..f8a72cf1543ffb4b24d7147c72a424df77ccd5cf 100644
--- a/cmake/lws_config.h.in
+++ b/cmake/lws_config.h.in
@@ -19,7 +19,6 @@
 
 #cmakedefine LWS_WITH_MBEDTLS
 #cmakedefine LWS_WITH_POLARSSL
-#cmakedefine LWS_WITH_ESP8266
 #cmakedefine LWS_WITH_ESP32
 
 #cmakedefine LWS_WITH_PLUGINS
diff --git a/lib/context.c b/lib/context.c
index 0b504896a6dc2c76cb0dc7792e13a353c48a524e..fb27fd68020fddd4225caebeb5329eb2840da785 100644
--- a/lib/context.c
+++ b/lib/context.c
@@ -590,7 +590,7 @@ lws_create_vhost(struct lws_context *context,
 #endif
 
 	vh->iface = info->iface;
-#if !defined(LWS_WITH_ESP8266) && !defined(LWS_WITH_ESP32) && \
+#if !defined(LWS_WITH_ESP32) && \
     !defined(OPTEE_TA) && !defined(WIN32)
 	vh->bind_iface = info->bind_iface;
 #endif
@@ -773,7 +773,6 @@ lws_create_vhost(struct lws_context *context,
 #endif
 
 	vh->listen_port = info->port;
-#if !defined(LWS_WITH_ESP8266)
 	vh->http_proxy_port = 0;
 	vh->http_proxy_address[0] = '\0';
 #if defined(LWS_WITH_SOCKS5)
@@ -810,7 +809,6 @@ lws_create_vhost(struct lws_context *context,
 			lws_set_socks(vh, p);
 #endif
 	}
-#endif
 #endif
 
 	vh->ka_time = info->ka_time;
diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c
index b1c3ff3bd5d5ccb319aa6972f24693ef2ef97f6d..a4f6dad2182a31525745747303550171f83c1d18 100644
--- a/lib/libwebsockets.c
+++ b/lib/libwebsockets.c
@@ -290,17 +290,6 @@ lws_close_free_wsi(struct lws *wsi, enum lws_close_status reason)
 		return;
 
 	lws_access_log(wsi);
-#if defined(LWS_WITH_ESP8266)
-	if (wsi->premature_rx)
-		lws_free(wsi->premature_rx);
-
-	if (wsi->pending_send_completion &&
-	    !wsi->close_is_pending_send_completion) {
-		lwsl_notice("delaying close\n");
-		wsi->close_is_pending_send_completion = 1;
-		return;
-	}
-#endif
 
 	/* we're closing, losing some rx is OK */
 	lws_header_table_force_to_detachable_state(wsi);
@@ -564,10 +553,6 @@ lws_close_free_wsi(struct lws *wsi, enum lws_close_status reason)
 				reason & 0xff;
 		}
 
-#if defined (LWS_WITH_ESP8266)
-		wsi->close_is_pending_send_completion = 1;
-#endif
-
 		lwsl_debug("waiting for chance to send close\n");
 		wsi->waiting_to_send_close_frame = 1;
 		wsi->state = LWSS_WAITING_TO_SEND_CLOSE_NOTIFICATION;
@@ -688,10 +673,6 @@ just_kill_connection:
 	else
 		lws_same_vh_protocol_remove(wsi);
 
-#if defined(LWS_WITH_ESP8266)
-	espconn_disconnect(wsi->desc.sockfd);
-#endif
-
 	wsi->state = LWSS_DEAD_SOCKET;
 	lws_free_set_NULL(wsi->rxflow_buffer);
 
@@ -989,13 +970,9 @@ lws_get_peer_simple(struct lws *wsi, char *name, int namelen)
 	}
 
 	return lws_plat_inet_ntop(af, q, name, namelen);
-#else
-#if defined(LWS_WITH_ESP8266)
-	return lws_plat_get_peer_simple(wsi, name, namelen);
 #else
 	return NULL;
 #endif
-#endif
 }
 #endif
 
@@ -1493,15 +1470,9 @@ int user_callback_handle_rxflow(lws_callback_function callback_function,
 	return n;
 }
 
-#if defined(LWS_WITH_ESP8266)
-#undef strchr
-#define strchr ets_strchr
-#endif
-
 LWS_VISIBLE int
 lws_set_proxy(struct lws_vhost *vhost, const char *proxy)
 {
-#if !defined(LWS_WITH_ESP8266)
 	char *p;
 	char authstring[96];
 
@@ -1555,7 +1526,7 @@ lws_set_proxy(struct lws_vhost *vhost, const char *proxy)
 
 auth_too_long:
 	lwsl_err("proxy auth too long\n");
-#endif
+
 	return -1;
 }
 
@@ -1563,7 +1534,6 @@ auth_too_long:
 LWS_VISIBLE int
 lws_set_socks(struct lws_vhost *vhost, const char *socks)
 {
-#if !defined(LWS_WITH_ESP8266)
 	char *p_at, *p_colon;
 	char user[96];
 	char password[96];
@@ -1628,7 +1598,6 @@ lws_set_socks(struct lws_vhost *vhost, const char *socks)
 	return 0;
 
 bail:
-#endif
 	return -1;
 }
 #endif
@@ -1757,7 +1726,6 @@ static const char * const colours[] = {
 #ifndef LWS_PLAT_OPTEE
 LWS_VISIBLE void lwsl_emit_stderr(int level, const char *line)
 {
-#if !defined(LWS_WITH_ESP8266)
 	char buf[50];
 	static char tty;
 	int n, m = ARRAY_SIZE(colours) - 1;
@@ -1778,17 +1746,12 @@ LWS_VISIBLE void lwsl_emit_stderr(int level, const char *line)
 		fprintf(stderr, "%c%s%s%s%c[0m", 27, colours[m], buf, line, 27);
 	} else
 		fprintf(stderr, "%s%s", buf, line);
-#endif
 }
 #endif
 
 LWS_VISIBLE void _lws_logv(int filter, const char *format, va_list vl)
 {
-#if defined(LWS_WITH_ESP8266)
-	char buf[128];
-#else
 	char buf[256];
-#endif
 	int n;
 
 	if (!(log_level & filter))
@@ -1796,15 +1759,11 @@ LWS_VISIBLE void _lws_logv(int filter, const char *format, va_list vl)
 
 	n = vsnprintf(buf, sizeof(buf) - 1, format, vl);
 	(void)n;
-#if defined(LWS_WITH_ESP8266)
-	buf[sizeof(buf) - 1] = '\0';
-#else
 	/* vnsprintf returns what it would have written, even if truncated */
 	if (n > (int)sizeof(buf) - 1)
 		n = sizeof(buf) - 1;
 	if (n > 0)
 		buf[n] = '\0';
-#endif
 
 	lwsl_emit(filter, buf);
 }
diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h
index fe2d20281c572be183bfccfe62f5db090a939c14..b437b8dffd12fd9863ac3fc76d3f0adc5f5c24af 100644
--- a/lib/libwebsockets.h
+++ b/lib/libwebsockets.h
@@ -39,12 +39,7 @@ extern "C" {
  * CARE: everything using cmake defines needs to be below here
  */
 
-#if defined(LWS_WITH_ESP8266)
-struct sockaddr_in;
-#define LWS_POSIX 0
-#else
 #define LWS_POSIX 1
-#endif
 
 #if defined(LWS_HAS_INTPTR_T)
 #include <stdint.h>
@@ -128,7 +123,7 @@ typedef unsigned long long lws_intptr_t;
 #define LWS_O_CREAT O_CREAT
 #define LWS_O_TRUNC O_TRUNC
 
-#if !defined(LWS_WITH_ESP8266) && !defined(OPTEE_TA) && !defined(LWS_WITH_ESP32)
+#if !defined(OPTEE_TA) && !defined(LWS_WITH_ESP32)
 #include <poll.h>
 #include <netdb.h>
 #define LWS_INVALID_FILE -1
@@ -282,10 +277,6 @@ lwsl_timestamp(int level, char *p, int len);
  *  active
  */
 
-#if defined(LWS_WITH_ESP8266)
-#undef _DEBUG
-#endif
-
 #ifdef _DEBUG
 #if defined(LWS_WITH_NO_LOGS)
 /* notice, warn and log are always compiled in */
@@ -436,72 +427,6 @@ struct lws_pollfd {
 #else
 
 
-#if defined(LWS_WITH_ESP8266)
-
-#include <user_interface.h>
-#include <espconn.h>
-
-typedef struct espconn * lws_sockfd_type;
-typedef void * lws_filefd_type;
-#define lws_sockfd_valid(sfd) (!!sfd)
-struct pollfd {
-	lws_sockfd_type fd; /**< fd related to */
-	short events; /**< which POLL... events to respond to */
-	short revents; /**< which POLL... events occurred */
-};
-#define POLLIN		0x0001
-#define POLLPRI		0x0002
-#define POLLOUT		0x0004
-#define POLLERR		0x0008
-#define POLLHUP		0x0010
-#define POLLNVAL	0x0020
-
-struct lws_vhost;
-
-lws_sockfd_type esp8266_create_tcp_listen_socket(struct lws_vhost *vh);
-void esp8266_tcp_stream_accept(lws_sockfd_type fd, struct lws *wsi);
-
-#include <os_type.h>
-#include <osapi.h>
-#include "ets_sys.h"
-
-int ets_snprintf(char *str, size_t size, const char *format, ...) LWS_FORMAT(3);
-#define snprintf  ets_snprintf
-
-typedef os_timer_t uv_timer_t;
-typedef void uv_cb_t(uv_timer_t *);
-
-void os_timer_disarm(void *);
-void os_timer_setfn(os_timer_t *, os_timer_func_t *, void *);
-
-void ets_timer_arm_new(os_timer_t *, int, int, int);
-
-//void os_timer_arm(os_timer_t *, int, int);
-
-#define UV_VERSION_MAJOR 1
-
-#define lws_uv_getloop(a, b) (NULL)
-
-static inline void uv_timer_init(void *l, uv_timer_t *t)
-{
-	(void)l;
-	memset(t, 0, sizeof(*t));
-	os_timer_disarm(t);
-}
-
-static inline void uv_timer_start(uv_timer_t *t, uv_cb_t *cb, int first, int rep)
-{
-	os_timer_setfn(t, (os_timer_func_t *)cb, t);
-	/* ms, repeat */
-	os_timer_arm(t, first, !!rep);
-}
-
-static inline void uv_timer_stop(uv_timer_t *t)
-{
-	os_timer_disarm(t);
-}
-
-#else
 #if defined(LWS_WITH_ESP32)
 
 typedef int lws_sockfd_type;
@@ -708,7 +633,6 @@ typedef int lws_sockfd_type;
 typedef int lws_filefd_type;
 #define lws_sockfd_valid(sfd) (sfd >= 0)
 #endif
-#endif
 
 #define lws_pollfd pollfd
 #define LWS_POLLHUP (POLLHUP|POLLERR)
@@ -5104,7 +5028,7 @@ lws_get_peer_addresses(struct lws *wsi, lws_sockfd_type fd, char *name,
  */
 LWS_VISIBLE LWS_EXTERN const char *
 lws_get_peer_simple(struct lws *wsi, char *name, int namelen);
-#if !defined(LWS_WITH_ESP8266) && !defined(LWS_WITH_ESP32)
+#if !defined(LWS_WITH_ESP32)
 /**
  * lws_interface_to_sa() - Convert interface name or IP to sockaddr struct
  *
diff --git a/lib/output.c b/lib/output.c
index c3cca1fc14870fbd7a1c23879dac14b203bf7e3b..a0c781f820e85121516138e5e0f59c6b8c257b79 100644
--- a/lib/output.c
+++ b/lib/output.c
@@ -65,15 +65,10 @@ int lws_issue_raw(struct lws *wsi, unsigned char *buf, size_t len)
 		char dump[20];
 		strncpy(dump, (char *)buf, sizeof(dump) - 1);
 		dump[sizeof(dump) - 1] = '\0';
-#if defined(LWS_WITH_ESP8266)
-		lwsl_err("** %p: Sending new %lu (%s), pending truncated ...\n",
-			 wsi, (unsigned long)len, dump);
-#else
 		lwsl_err("** %p: Sending new %lu (%s), pending truncated ...\n"
 			 "   It's illegal to do an lws_write outside of\n"
 			 "   the writable callback: fix your code\n",
 			 wsi, (unsigned long)len, dump);
-#endif
 		assert(0);
 
 		return -1;
@@ -101,12 +96,6 @@ int lws_issue_raw(struct lws *wsi, unsigned char *buf, size_t len)
 	n += LWS_PRE + 4;
 	if (n > len)
 		n = (int)len;
-#if defined(LWS_WITH_ESP8266)	
-	if (wsi->pending_send_completion) {
-		n = 0;
-		goto handle_truncated_send;
-	}
-#endif
 
 	/* nope, send it on the socket directly */
 	lws_latency_pre(context, wsi);
diff --git a/lib/plat/lws-plat-esp8266.c b/lib/plat/lws-plat-esp8266.c
deleted file mode 100644
index 5bd343aadc30c8b0769a5d13f98c8d690e16efe0..0000000000000000000000000000000000000000
--- a/lib/plat/lws-plat-esp8266.c
+++ /dev/null
@@ -1,743 +0,0 @@
-#include "private-libwebsockets.h"
-
-#include "ip_addr.h"
-
-/* forced into this because new espconn accepted callbacks carry no context ptr */
-static struct lws_context *hacky_context;
-static unsigned int time_high, ot;
-
-int
-lws_plat_socket_offset(void)
-{
-	return 0;
-}
-
-/*
- * included from libwebsockets.c for esp8266 builds
- */
-
-unsigned long long time_in_microseconds(void)
-{
-	unsigned int t = system_get_time();
-	
-	if (ot > t)
-		time_high++;
-	ot = t;
-	
-	return (((long long)time_high) << 32) | t;
-}
-
-int gettimeofday(struct timeval *tv, void *tz)
-{
-	unsigned long long t = time_in_microseconds();
-	
-	tv->tv_sec = t / 1000000;
-	tv->tv_usec = t % 1000000;
-
-	return 0;
-}
-
-time_t time(time_t *tloc)
-{
-	unsigned long long t = time_in_microseconds();
-
-	if (tloc)
-		*tloc = t / 1000000;
-
-	return 0;
-}
-
-
-int
-lws_plat_pipe_create(struct lws *wsi)
-{
-	return 1;
-}
-
-int
-lws_plat_pipe_signal(struct lws *wsi)
-{
-	return 1;
-}
-
-void
-lws_plat_pipe_close(struct lws *wsi)
-{
-}
-
-LWS_VISIBLE int
-lws_get_random(struct lws_context *context, void *buf, int len)
-{
-//	return read(context->fd_random, (char *)buf, len);
-	return 0;
-}
-
-LWS_VISIBLE int
-lws_send_pipe_choked(struct lws *wsi)
-{
-	return wsi->pending_send_completion;
-}
-
-LWS_VISIBLE struct lws *
-wsi_from_fd(const struct lws_context *context, lws_sockfd_type fd)
-{
-	int n;
-
-	for (n = 0; n < context->max_fds; n++)
-		if (context->connpool[n] == fd)
-			return (struct lws *)context->connpool[n + context->max_fds];
-
-	return NULL;
-}
-
-LWS_VISIBLE int
-lws_ssl_capable_write_no_ssl(struct lws *wsi, unsigned char *buf, int len)
-{
-	//lwsl_notice("%s: wsi %p: len %d\n", __func__, wsi, len);	
-	
-	wsi->pending_send_completion++;
-	espconn_send(wsi->desc.sockfd, buf, len);
-	
-	return len;
-}
-
-void abort(void)
-{
-	while(1) ;
-}
-
-void exit(int n)
-{
-	abort();
-}
-
-void _sint(void *s)
-{
-}
-
-LWS_VISIBLE int
-insert_wsi(struct lws_context *context, struct lws *wsi)
-{
-	(void)context;
-	(void)wsi;
-
-	return 0;
-}
-
-LWS_VISIBLE int
-delete_from_fd(struct lws_context *context, lws_sockfd_type fd)
-{
-	(void)context;
-	(void)fd;
-
-	return 1;
-}
-
-struct tm *localtime(const time_t *timep)
-{
-	return NULL;
-}
-struct tm *localtime_r(const time_t *timep, struct tm *t)
-{
-	return NULL;
-}
-
-int atoi(const char *s)
-{
-	int n = 0;
-
-	while (*s && (*s >= '0' && *s <= '9'))
-		n = (n * 10) + ((*s++) - '0');
-
-	return n;
-}
-
-#undef isxdigit
-int isxdigit(int c)
-{
-	if (c >= 'A' && c <= 'F')
-		return 1;
-
-	if (c >= 'a' && c <= 'f')
-		return 1;
-
-	if (c >= '0' && c <= '9')
-		return 1;
-
-	return 0;
-}
-
-int strcasecmp(const char *s1, const char *s2)
-{
-	char a, b;
-	while (*s1 && *s2) {
-		a = *s1++;
-		b = *s2++;
-
-		if (a == b)
-			continue;
-
-		if (a >= 'a' && a <= 'z')
-			a -= 'a' - 'A';
-		if (b >= 'a' && b <= 'z')
-			b -= 'a' - 'A';
-
-		if (a != b)
-			return 1;
-	}
-
-	return 0;
-}
-
-LWS_VISIBLE int
-lws_poll_listen_fd(struct lws_pollfd *fd)
-{
-	return 0;
-}
-
-LWS_VISIBLE void lwsl_emit_syslog(int level, const char *line)
-{
-	extern void output_redirect(const char *str);
-	output_redirect(line);
-}
-
-LWS_VISIBLE LWS_EXTERN int
-_lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi)
-{
-	return 0;
-}
-
-LWS_VISIBLE int
-lws_plat_check_connection_error(struct lws *wsi)
-{
-	return 0;
-}
-
-LWS_VISIBLE int
-lws_plat_service(struct lws_context *context, int timeout_ms)
-{
-//	return _lws_plat_service_tsi(context, timeout_ms, 0);
-	return 0;
-}
-
-static int
-esp8266_find_free_conn(struct lws_context *context)
-{
-	int n;
-
-	for (n = 0; n < context->max_fds; n++)
-		if (!context->connpool[n]) {
-			lwsl_info(" using connpool %d\n", n);
-			return n;
-		}
-	
-	lwsl_err("%s: no free conns\n", __func__);
-	
-	return -1;
-}
-
-lws_sockfd_type
-esp8266_create_tcp_listen_socket(struct lws_vhost *vh)
-{
-	int n = esp8266_find_free_conn(vh->context);
-	struct espconn *conn;
-	
-	if (n < 0)
-		return NULL;
-	
-	conn = lws_zalloc(sizeof *conn, "listen skt");
-	if (!conn)
-		return NULL;
-	
-	vh->context->connpool[n] = conn;
-	
-	conn->type = ESPCONN_TCP;
-	conn->state = ESPCONN_NONE;
-	conn->proto.tcp = &vh->tcp;
-	
-	return conn;
-}
-
-const char *
-lws_plat_get_peer_simple(struct lws *wsi, char *name, int namelen)
-{
-	unsigned char *p = wsi->desc.sockfd->proto.tcp->remote_ip;
-
-	lws_snprintf(name, namelen, "%u.%u.%u.%u", p[0], p[1], p[2], p[3]);
-
-	return name;
-}
-
-LWS_VISIBLE int
-lws_ssl_capable_read_no_ssl(struct lws *wsi, unsigned char *buf, int len)
-{
-	//lwsl_notice("%s\n", __func__);
-	
-	if (!wsi->context->rxd)
-		return 0;
-
-	if (len < wsi->context->rxd_len)
-		lwsl_err("trunc read (%d vs %d)\n", len, wsi->context->rxd_len);
-	else
-		len = wsi->context->rxd_len;
-	
-	ets_memcpy(buf, wsi->context->rxd, len);
-	
-	wsi->context->rxd = NULL;
-	
-	return len;
-}
-
-static void
-cb_1Hz(void *arg)
-{
-	struct lws_context *context = arg;
-	struct lws_context_per_thread *pt = &context->pt[0];
-	struct lws *wsi;
-	struct lws_pollfd *pollfd;
-	int n;
-
-	/* Service any ah that has pending rx */
-	for (n = 0; n < context->max_http_header_pool; n++)
-		if (pt->ah_pool[n].rxpos != pt->ah_pool[n].rxlen) {
-			wsi = pt->ah_pool[n].wsi;
-			pollfd = &pt->fds[wsi->position_in_fds_table];
-			if (pollfd->events & LWS_POLLIN) {
-				pollfd->revents |= LWS_POLLIN;
-				lws_service_fd(context, pollfd);
-			}
-		}
-
-	/* handle timeouts */
-
-	lws_service_fd(context, NULL);
-}
-
-static void
-esp8266_cb_rx(void *arg, char *data, unsigned short len)
-{
-	struct espconn *conn = arg;
-	struct lws *wsi = conn->reverse;
-	struct lws_context_per_thread *pt = &wsi->context->pt[0];
-	struct lws_pollfd pollfd;
-	int n = 0;
-
-	/*
-	 * if we're doing HTTP headers, and we have no ah, check if there is
-	 * a free ah, if not, have to buffer it
-	 */
-	if (!wsi->hdr_parsing_completed && !wsi->ah) {
-		for (n = 0; n < wsi->context->max_http_header_pool; n++)
-			if (!pt->ah_pool[n].in_use)
-				break;
-
-		n = n == wsi->context->max_http_header_pool;
-	}
-
-	if (!(pt->fds[wsi->position_in_fds_table].events & LWS_POLLIN) || n) {
-		wsi->premature_rx = realloc(wsi->premature_rx,
-					    wsi->prem_rx_size + len);
-		if (!wsi->premature_rx)
-			return;
-		os_memcpy((char *)wsi->premature_rx + wsi->prem_rx_size, data, len);
-		wsi->prem_rx_size += len;
-	//	lwsl_notice("%s: wsi %p: len %d BUFFERING\n", __func__, wsi, len);
-
-		if (n) /* we know it will fail, but we will get on the wait list */
-			n = lws_header_table_attach(wsi, 0);
-
-		(void)n;
-		return;
-	}
-
-	//lwsl_err("%s: wsi %p. len %d\n", __func__, wsi, len);
-
-        pollfd.fd = arg;
-        pollfd.events = LWS_POLLIN;
-        pollfd.revents = LWS_POLLIN;
-        
-        wsi->context->rxd = data;
-        wsi->context->rxd_len = len;
-
-        lws_service_fd(lws_get_context(wsi), &pollfd);
-
-}
-
-static void
-esp8266_cb_sent(void *arg)
-{
-	struct espconn *conn = arg;
-	struct lws *wsi = conn->reverse;
-	struct lws_context_per_thread *pt = &wsi->context->pt[(int)wsi->tsi];
-	
-//	lwsl_err("%s: wsi %p (psc %d) wsi->position_in_fds_table=%d\n", __func__, wsi, wsi->pending_send_completion, wsi->position_in_fds_table);
-	
-	wsi->pending_send_completion--;
-	if (wsi->close_is_pending_send_completion &&
-	    !wsi->pending_send_completion &&
-	    !lws_partial_buffered(wsi)) {
-		lwsl_notice("doing delayed close\n");
-		lws_close_free_wsi(wsi, LWS_CLOSE_STATUS_NOSTATUS);
-	}
-	
-	if (pt->fds[wsi->position_in_fds_table].events & LWS_POLLOUT) {
-		struct lws_pollfd pollfd;
-
-	        pollfd.fd = arg;
-	        pollfd.events = LWS_POLLOUT;
-	        pollfd.revents = LWS_POLLOUT;
-
-//	        lwsl_notice("informing POLLOUT\n");
-	        
-	        lws_service_fd(lws_get_context(wsi), &pollfd);
-	}
-}
-
-static void
-esp8266_cb_disconnected(void *arg)
-{
-	struct espconn *conn = arg;
-	struct lws *wsi = conn->reverse;
-	int n;
-
-	lwsl_notice("%s: %p\n", __func__, wsi);
-	
-	for (n = 0; n < hacky_context->max_fds; n++)
-		if (hacky_context->connpool[n] == arg) {
-			hacky_context->connpool[n] = NULL;
-			lwsl_info(" freed connpool %d\n", n);
-		}
-	
-	if (wsi) {
-		conn->reverse = NULL;
-		lws_close_free_wsi(wsi, LWS_CLOSE_STATUS_NOSTATUS);
-		lwsl_notice("closed ok\n");
-	}
-}
-
-static void
-esp8266_cb_recon(void *arg, signed char err)
-{
-	struct espconn *conn = arg;
-
-	lwsl_err("%s: wsi %p. err %d\n", __func__, conn->reverse, err);
-
-	conn->state = ESPCONN_CLOSE;		
-
-	esp8266_cb_disconnected(arg);	
-}
-
-/*
- * there is no reliable indication of which listen socket we were accepted on.
- */
-
-static void
-esp8266_cb_connect(void *arg)
-{
-	struct espconn *cs = arg;
-//	struct ip_addr *ipa = (struct ip_addr *)cs->proto.tcp->remote_ip;
-	struct lws_vhost *vh = hacky_context->vhost_list;
-//	struct ip_info info;
-	struct lws *wsi;
-	int n;
-
-	lwsl_notice("%s: (wsi coming): %p\n", __func__, cs->reverse);
-#if 0
-	wifi_get_ip_info(0, &info);
-	if (ip_addr_netcmp(ipa, &info.ip, &info.netmask)) {
-		/* we are on the same subnet as the AP, ie, connected to AP */
-		while (vh && strcmp(vh->name, "ap"))
-			vh = vh->vhost_next;
-	} else
-		while (vh && !strcmp(vh->name, "ap"))
-			vh = vh->vhost_next;
-
-	if (!vh)
-		goto bail;
-#endif
-	n = esp8266_find_free_conn(hacky_context);
-	if (n < 0)
-		goto bail;
-	
-	hacky_context->connpool[n] = cs;
-	
-	espconn_recv_hold(cs);
-
-	wsi = lws_adopt_socket_vhost(vh, cs);
-	if (!wsi)
-		goto bail;
-	
-	lwsl_err("%s: wsi %p (using free_conn %d): vh %s\n", __func__, wsi, n, vh->name);
-
-	espconn_regist_recvcb(cs, esp8266_cb_rx);
-	espconn_regist_reconcb(cs, esp8266_cb_recon);
-	espconn_regist_disconcb(cs, esp8266_cb_disconnected);
-	espconn_regist_sentcb(cs, esp8266_cb_sent);
-	
-	espconn_set_opt(cs, ESPCONN_NODELAY | ESPCONN_REUSEADDR);
-	espconn_regist_time(cs, 7200, 1);
-
-	return;
-
-bail:
-	lwsl_err("%s: bailed]n", __func__);
-	espconn_disconnect(cs);
-}
-
-void
-esp8266_tcp_stream_bind(lws_sockfd_type fd, int port, struct lws *wsi)
-{
-	fd->proto.tcp->local_port = port;
-	fd->reverse = wsi;
-	
-	hacky_context = wsi->context;
-	
-	espconn_regist_connectcb(fd, esp8266_cb_connect);
-	/* hmmm it means, listen() + accept() */
-	espconn_accept(fd);
-
-	espconn_tcp_set_max_con_allow(fd, 10);
-}
-
-void
-esp8266_tcp_stream_accept(lws_sockfd_type fd, struct lws *wsi)
-{
-	int n;
-
-	fd->reverse = wsi;
-
-	for (n = 0; n < wsi->context->max_fds ; n++)
-		if (wsi->context->connpool[n] == wsi->desc.sockfd)
-			wsi->position_in_fds_table = n;
-}
-
-LWS_VISIBLE int
-lws_plat_set_socket_options(struct lws_vhost *vhost, lws_sockfd_type fd)
-{
-	return 0;
-}
-
-LWS_VISIBLE void
-lws_plat_drop_app_privileges(struct lws_context_creation_info *info)
-{
-}
-
-LWS_VISIBLE int
-lws_plat_context_early_init(void)
-{
-	espconn_tcp_set_max_con(12);
-
-	return 0;
-}
-
-LWS_VISIBLE void
-lws_plat_context_early_destroy(struct lws_context *context)
-{
-}
-
-LWS_VISIBLE void
-lws_plat_context_late_destroy(struct lws_context *context)
-{
-#if 0
-	struct lws_context_per_thread *pt = &context->pt[0];
-	int m = context->count_threads;
-
-	if (context->lws_lookup)
-		lws_free(context->lws_lookup);
-
-	while (m--) {
-		close(pt->dummy_pipe_fds[0]);
-		close(pt->dummy_pipe_fds[1]);
-		pt++;
-	}
-#endif
-//	close(context->fd_random);
-}
-
-/* cast a struct sockaddr_in6 * into addr for ipv6 */
-
-LWS_VISIBLE int
-lws_interface_to_sa(int ipv6, const char *ifname, struct sockaddr_in *addr,
-		    size_t addrlen)
-{
-	return 0;
-}
-
-LWS_VISIBLE void
-lws_plat_insert_socket_into_fds(struct lws_context *context, struct lws *wsi)
-{
-	struct lws_context_per_thread *pt = &wsi->context->pt[(int)wsi->tsi];
-
-	context->connpool[wsi->position_in_fds_table + context->max_fds] = (lws_sockfd_type)wsi;
-	wsi->desc.sockfd->reverse = wsi;
-	pt->fds_count++;
-}
-
-LWS_VISIBLE void
-lws_plat_delete_socket_from_fds(struct lws_context *context,
-						struct lws *wsi, int m)
-{
-	struct lws_context_per_thread *pt = &wsi->context->pt[(int)wsi->tsi];	
-	int n;
-	
-	for (n = 0; n < wsi->context->max_fds; n++)
-		if (wsi->context->connpool[n] == wsi->desc.sockfd) {
-			wsi->context->connpool[n] = NULL;
-			wsi->context->connpool[n + wsi->context->max_fds] = NULL;
-			lwsl_notice(" freed connpool %d\n", n);
-		}
-	
-	wsi->desc.sockfd->reverse = NULL;
-	pt->fds_count--;
-}
-
-LWS_VISIBLE void
-lws_plat_service_periodic(struct lws_context *context)
-{
-}
-
-LWS_VISIBLE int
-lws_plat_change_pollfd(struct lws_context *context,
-		       struct lws *wsi, struct lws_pollfd *pfd)
-{
-	void *p;
-
-	//lwsl_notice("%s: %p: wsi->pift=%d, events %d\n",
-	//		__func__, wsi, wsi->position_in_fds_table, pfd->events);
-	
-	if (pfd->events & LWS_POLLIN) {
-		if (wsi->premature_rx) {
-			lwsl_notice("replaying buffered rx: wsi %p\n", wsi);
-			p = wsi->premature_rx;
-			wsi->premature_rx = NULL;
-			esp8266_cb_rx(wsi->desc.sockfd,
-				      (char *)p + wsi->prem_rx_pos,
-				      wsi->prem_rx_size - wsi->prem_rx_pos);
-			wsi->prem_rx_size = 0;
-			wsi->prem_rx_pos = 0;
-			lws_free(p);
-		}
-		if (espconn_recv_unhold(wsi->desc.sockfd) < 0)
-			return -1;
-	} else
-		if (espconn_recv_hold(wsi->desc.sockfd) < 0)
-			return -1;
-	
-	if (!(pfd->events & LWS_POLLOUT))
-		return 0;
-	
-	if (!wsi->pending_send_completion) {
-		pfd->revents |= LWS_POLLOUT;
-
-//		lwsl_notice("doing POLLOUT\n");
-		lws_service_fd(lws_get_context(wsi), pfd);
-	} //else
-		//lwsl_notice("pending sc\n");
-
-	return 0;
-}
-
-LWS_VISIBLE const char *
-lws_plat_inet_ntop(int af, const void *src, char *dst, int cnt)
-{
-//	return inet_ntop(af, src, dst, cnt);
-	return 0;
-}
-
-LWS_VISIBLE int
-lws_plat_inet_pton(int af, const char *src, void *dst)
-{
-	//return inet_pton(af, src, dst);
-	return 1;
-}
-
-LWS_VISIBLE int
-lws_plat_init(struct lws_context *context,
-	      struct lws_context_creation_info *info)
-{
-//	struct lws_context_per_thread *pt = &context->pt[0];
-//	int n = context->count_threads, fd;
-
-	/* master context has the global fd lookup array */
-	context->connpool = lws_zalloc(sizeof(struct espconn *) *
-					 context->max_fds * 2, "connpool");
-	if (context->connpool == NULL) {
-		lwsl_err("OOM on lws_lookup array for %d connections\n",
-			 context->max_fds);
-		return 1;
-	}
-
-	lwsl_notice(" mem: platform fd map: %5u bytes\n",
-		    sizeof(struct espconn *) * context->max_fds);
-//	fd = open(SYSTEM_RANDOM_FILEPATH, O_RDONLY);
-
-//	context->fd_random = fd;
-//	if (context->fd_random < 0) {
-//		lwsl_err("Unable to open random device %s %d\n",
-//			 SYSTEM_RANDOM_FILEPATH, context->fd_random);
-//		return 1;
-//	}
-
-        os_memset(&context->to_timer, 0, sizeof(os_timer_t));
-        os_timer_disarm(&context->to_timer);
-        os_timer_setfn(&context->to_timer, (os_timer_func_t *)cb_1Hz, context);
-        os_timer_arm(&context->to_timer, 1000, 1);
-
-	if (!lws_libev_init_fd_table(context) &&
-	    !lws_libuv_init_fd_table(context) &&
-	    !lws_libevent_init_fd_table(context)) {
-		/* otherwise libev handled it instead */
-#if 0
-		while (n--) {
-			if (pipe(pt->dummy_pipe_fds)) {
-				lwsl_err("Unable to create pipe\n");
-				return 1;
-			}
-
-			/* use the read end of pipe as first item */
-			pt->fds[0].fd = pt->dummy_pipe_fds[0];
-			pt->fds[0].events = LWS_POLLIN;
-			pt->fds[0].revents = 0;
-			pt->fds_count = 1;
-			pt++;
-		}
-#endif
-	}
-
-
-#ifdef LWS_WITH_PLUGINS
-	if (info->plugin_dirs)
-		lws_plat_plugins_init(context, info->plugin_dirs);
-#endif
-
-	return 0;
-}
-
-LWS_VISIBLE int
-lws_plat_write_cert(struct lws_vhost *vhost, int is_key, int fd, void *buf,
-			int len)
-{
-	return 1;
-}
-
-LWS_VISIBLE int
-lws_plat_write_file(const char *filename, void *buf, int len)
-{
-	return 1;
-}
-
-LWS_VISIBLE int
-lws_plat_read_file(const char *filename, void *buf, int len)
-{
-	return -1;
-}
-
-LWS_VISIBLE int
-lws_plat_recommended_rsa_bits(void)
-{
-	/*
-	 * 2048-bit key generation takes up to a minute on ESP32, 4096
-	 * is like 15 minutes +
-	 */
-	return 2048;
-}
diff --git a/lib/pollfd.c b/lib/pollfd.c
index 8f44d1e8af7218d14592171fbf7de8bed33cca85..8d63c46818eab026466690fc316c54d4f815a959 100644
--- a/lib/pollfd.c
+++ b/lib/pollfd.c
@@ -236,7 +236,7 @@ insert_wsi_socket_into_fds(struct lws_context *context, struct lws *wsi)
 		return 1;
 	}
 
-#if !defined(_WIN32) && !defined(LWS_WITH_ESP8266)
+#if !defined(_WIN32)
 	if (wsi->desc.sockfd - lws_plat_socket_offset() >= context->max_fds) {
 		lwsl_err("Socket fd %d is too high (%d) offset %d\n",
 			 wsi->desc.sockfd, context->max_fds, lws_plat_socket_offset());
@@ -256,10 +256,7 @@ insert_wsi_socket_into_fds(struct lws_context *context, struct lws *wsi)
 	lws_pt_lock(pt);
 	pt->count_conns++;
 	insert_wsi(context, wsi);
-#if defined(LWS_WITH_ESP8266)
-	if (wsi->position_in_fds_table == -1)
-#endif
-		wsi->position_in_fds_table = pt->fds_count;
+	wsi->position_in_fds_table = pt->fds_count;
 
 	pt->fds[wsi->position_in_fds_table].fd = wsi->desc.sockfd;
 #if LWS_POSIX
@@ -296,11 +293,9 @@ remove_wsi_socket_from_fds(struct lws *wsi)
 {
 	struct lws_context *context = wsi->context;
 	struct lws_pollargs pa = { wsi->desc.sockfd, 0, 0 };
-#if !defined(LWS_WITH_ESP8266)
 	struct lws_context_per_thread *pt = &context->pt[(int)wsi->tsi];
 	struct lws *end_wsi;
 	int v;
-#endif
 	int m, ret = 0;
 
 	if (wsi->parent_carries_io) {
@@ -308,7 +303,7 @@ remove_wsi_socket_from_fds(struct lws *wsi)
 		return 0;
 	}
 
-#if !defined(_WIN32) && !defined(LWS_WITH_ESP8266)
+#if !defined(_WIN32)
 	if (wsi->desc.sockfd - lws_plat_socket_offset() > context->max_fds) {
 		lwsl_err("fd %d too high (%d)\n", wsi->desc.sockfd,
 			 context->max_fds);
@@ -326,7 +321,6 @@ remove_wsi_socket_from_fds(struct lws *wsi)
 	/* the guy who is to be deleted's slot index in pt->fds */
 	m = wsi->position_in_fds_table;
 	
-#if !defined(LWS_WITH_ESP8266)
 	lws_libev_io(wsi, LWS_EV_STOP | LWS_EV_READ | LWS_EV_WRITE |
 			  LWS_EV_PREPARE_DELETION);
 	lws_libuv_io(wsi, LWS_EV_STOP | LWS_EV_READ | LWS_EV_WRITE |
@@ -340,10 +334,8 @@ remove_wsi_socket_from_fds(struct lws *wsi)
 
 	/* have the last guy take up the now vacant slot */
 	pt->fds[m] = pt->fds[pt->fds_count - 1];
-#endif
 	/* this decrements pt->fds_count */
 	lws_plat_delete_socket_from_fds(context, wsi, m);
-#if !defined(LWS_WITH_ESP8266)
 	v = (int) pt->fds[m].fd;
 	/* end guy's "position in fds table" is now the deletion guy's old one */
 	end_wsi = wsi_from_fd(context, v);
@@ -377,7 +369,7 @@ remove_wsi_socket_from_fds(struct lws *wsi)
 	    wsi->vhost->protocols[0].callback(wsi, LWS_CALLBACK_UNLOCK_POLL,
 					      wsi->user_space, (void *) &pa, 1))
 		ret = -1;
-#endif
+
 	return ret;
 }
 
diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h
index f96688f2bc19cc5e0ba0accd0e30bf0e10f0b397..9ce8a73d5d57757af0d5972ce644e0cd1cb18c02 100644
--- a/lib/private-libwebsockets.h
+++ b/lib/private-libwebsockets.h
@@ -49,54 +49,8 @@ typedef struct { long double x, y; } _Float128;
 #define SOMAXCONN 3
 #endif
 
-#if defined(LWS_WITH_ESP8266)
-#include <user_interface.h>
-#define assert(n)
-
-/* rom-provided stdc functions for free, ensure use these instead of libc ones */
-
-int ets_vsprintf(char *str, const char *format, va_list argptr);
-int ets_vsnprintf(char *buffer, size_t sizeOfBuffer,  const char *format, va_list argptr);
-int ets_snprintf(char *str, size_t size, const char *format, ...);
-int ets_sprintf(char *str, const char *format, ...);
-int os_printf_plus(const char *format, ...);
-#undef malloc
-#undef realloc
-#undef free
-void *pvPortMalloc(size_t s, const char *f, int line);
-#define malloc(s) pvPortMalloc(s, "", 0)
-void *pvPortRealloc(void *p, size_t s, const char *f, int line);
-#define realloc(p, s) pvPortRealloc(p, s, "", 0)
-void vPortFree(void *p, const char *f, int line);
-#define free(p) vPortFree(p, "", 0)
-#undef memcpy
-void *ets_memcpy(void *dest, const void *src, size_t n);
-#define memcpy ets_memcpy
-void *ets_memset(void *dest, int v, size_t n);
-#define memset ets_memset
-char *ets_strcpy(char *dest, const char *src);
-#define strcpy ets_strcpy
-char *ets_strncpy(char *dest, const char *src, size_t n);
-#define strncpy ets_strncpy
-char *ets_strstr(const char *haystack, const char *needle);
-#define strstr ets_strstr
-int ets_strcmp(const char *s1, const char *s2);
-int ets_strncmp(const char *s1, const char *s2, size_t n);
-#define strcmp ets_strcmp
-#define strncmp ets_strncmp
-size_t ets_strlen(const char *s);
-#define strlen ets_strlen
-void *ets_memmove(void *dest, const void *src, size_t n);
-#define memmove ets_memmove
-char *ets_strchr(const char *s, int c);
-#define strchr_ets_strchr
-#undef _DEBUG
-#include <osapi.h>
-
-#else
 #define STORE_IN_ROM
 #include <assert.h>
-#endif
 #if LWS_MAX_SMP > 1
 #include <pthread.h>
 #endif
@@ -180,17 +134,7 @@ int fork(void);
 #endif
 #include <netdb.h>
 #include <signal.h>
-#ifdef LWS_WITH_ESP8266
-#include <sockets.h>
-#define vsnprintf ets_vsnprintf
-#define snprintf ets_snprintf
-#define sprintf ets_sprintf
-
-int kill(int pid, int sig);
-
-#else
 #include <sys/socket.h>
-#endif
 #ifdef LWS_WITH_HTTP_PROXY
 #include <hubbub/hubbub.h>
 #include <hubbub/parser.h>
@@ -198,7 +142,7 @@ int kill(int pid, int sig);
 #if defined(LWS_BUILTIN_GETIFADDRS)
  #include "./misc/getifaddrs.h"
 #else
- #if !defined(LWS_WITH_ESP8266) && !defined(LWS_WITH_ESP32)
+ #if !defined(LWS_WITH_ESP32)
  #if defined(__HAIKU__)
    #define _BSD_SOURCE
  #endif
@@ -211,12 +155,12 @@ int kill(int pid, int sig);
 #elif defined (__sun) || defined(__HAIKU__)
 #include <syslog.h>
 #else
-#if !defined(LWS_WITH_ESP8266)  && !defined(LWS_WITH_ESP32)
+#if !defined(LWS_WITH_ESP32)
 #include <sys/syslog.h>
 #endif
 #endif
 #include <netdb.h>
-#if !defined(LWS_WITH_ESP8266) && !defined(LWS_WITH_ESP32)
+#if !defined(LWS_WITH_ESP32)
 #include <sys/mman.h>
 #include <sys/un.h>
 #include <netinet/in.h>
@@ -252,17 +196,9 @@ int kill(int pid, int sig);
 
 #define lws_set_blocking_send(wsi)
 
-#if defined(LWS_WITH_ESP8266)
-#define lws_socket_is_valid(x) ((x) != NULL)
-#define LWS_SOCK_INVALID (NULL)
-struct lws;
-const char *
-lws_plat_get_peer_simple(struct lws *wsi, char *name, int namelen);
-#else
 #define lws_socket_is_valid(x) (x >= 0)
 #define LWS_SOCK_INVALID (-1)
 #endif
-#endif
 
 #ifndef LWS_HAVE_BZERO
 #ifndef bzero
@@ -333,25 +269,6 @@ static inline int compatible_close(int fd) { return close(fd); }
 #include <gettimeofday.h>
 #endif
 
-#if defined(LWS_WITH_ESP8266)
-#undef compatible_close
-#define compatible_close(fd) { fd->state=ESPCONN_CLOSE; espconn_delete(fd); }
-lws_sockfd_type
-esp8266_create_tcp_stream_socket(void);
-void
-esp8266_tcp_stream_bind(lws_sockfd_type fd, int port, struct lws *wsi);
-#ifndef BIG_ENDIAN
-#define BIG_ENDIAN    4321  /* to show byte order (taken from gcc) */
-#endif
-#ifndef LITTLE_ENDIAN
-#define LITTLE_ENDIAN 1234
-#endif
-#ifndef BYTE_ORDER
-#define BYTE_ORDER LITTLE_ENDIAN
-#endif
-#endif
-
-
 #if defined(WIN32) || defined(_WIN32)
 
 #ifndef BIG_ENDIAN
@@ -894,9 +811,6 @@ struct lws_context_per_thread {
 #endif
 	struct lws_pollfd *fds;
 	volatile struct lws_foreign_thread_pollfd * volatile foreign_pfd_list;
-#if defined(LWS_WITH_ESP8266)
-	struct lws **lws_vs_fds_index;
-#endif
 	struct lws *rx_draining_ext_list;
 	struct lws *tx_draining_ext_list;
 	struct lws *timeout_list;
@@ -1005,7 +919,6 @@ struct http2_settings {
 struct lws_tls_ss_pieces;
 
 struct lws_vhost {
-#if !defined(LWS_WITH_ESP8266)
 	char http_proxy_address[128];
 	char proxy_basic_auth_token[128];
 #if defined(LWS_WITH_HTTP2)
@@ -1015,11 +928,6 @@ struct lws_vhost {
 	char socks_proxy_address[128];
 	char socks_user[96];
 	char socks_password[96];
-#endif
-#endif
-#if defined(LWS_WITH_ESP8266)
-	/* listen sockets need a place to hang their hat */
-	esp_tcp tcp;
 #endif
 	struct lws_conn_stats conn_stats;
 	struct lws_context *context;
@@ -1030,7 +938,7 @@ struct lws_vhost {
 	const char *iface;
 	char *alloc_cert_path;
 	char *key_path;
-#if !defined(LWS_WITH_ESP8266) && !defined(LWS_WITH_ESP32) && !defined(OPTEE_TA) && !defined(WIN32)
+#if !defined(LWS_WITH_ESP32) && !defined(OPTEE_TA) && !defined(WIN32)
 	int bind_iface;
 #endif
 	const struct lws_protocols *protocols;
@@ -1149,15 +1057,8 @@ struct lws_context {
 #ifdef _WIN32
 /* different implementation between unix and windows */
 	struct lws_fd_hashtable fd_hashtable[FD_HASHTABLE_MODULUS];
-#else
-#if defined(LWS_WITH_ESP8266)
-	struct espconn **connpool; /* .reverse points to the wsi */
-	void *rxd;
-	int rxd_len;
-	os_timer_t to_timer;
 #else
 	struct lws **lws_lookup;  /* fd to wsi */
-#endif
 #endif
 	struct lws_vhost *vhost_list;
 	struct lws_vhost *vhost_pending_destruction_list;
@@ -1948,11 +1849,6 @@ struct lws {
 	/* truncated send handling */
 	unsigned char *trunc_alloc; /* non-NULL means buffering in progress */
 
-#if defined (LWS_WITH_ESP8266)
-	void *premature_rx;
-	unsigned short prem_rx_size, prem_rx_pos;
-#endif
-
 #ifndef LWS_NO_EXTENSIONS
 	const struct lws_extension *active_extensions[LWS_MAX_EXTENSIONS_ACTIVE];
 	void *act_ext_user[LWS_MAX_EXTENSIONS_ACTIVE];
@@ -2019,10 +1915,6 @@ struct lws {
 	unsigned int rxflow_will_be_applied:1;
 	unsigned int event_pipe:1;
 
-#if defined(LWS_WITH_ESP8266)
-	unsigned int pending_send_completion:3;
-	unsigned int close_is_pending_send_completion:1;
-#endif
 #ifdef LWS_WITH_ACCESS_LOG
 	unsigned int access_log_pending:1;
 #endif
@@ -2148,7 +2040,7 @@ lws_b64_selftest(void);
 LWS_EXTERN int
 lws_service_flag_pending(struct lws_context *context, int tsi);
 
-#if defined(_WIN32) || defined(LWS_WITH_ESP8266)
+#if defined(_WIN32)
 LWS_EXTERN struct lws *
 wsi_from_fd(const struct lws_context *context, lws_sockfd_type fd);
 
@@ -2359,11 +2251,9 @@ LWS_EXTERN int get_daemonize_pid();
 #define get_daemonize_pid() (0)
 #endif
 
-#if !defined(LWS_WITH_ESP8266)
 LWS_EXTERN int LWS_WARN_UNUSED_RESULT
 interface_to_sa(struct lws_vhost *vh, const char *ifname,
 		struct sockaddr_in *addr, size_t addrlen);
-#endif
 LWS_EXTERN void lwsl_emit_stderr(int level, const char *line);
 
 #ifndef LWS_OPENSSL_SUPPORT
diff --git a/lib/server/server-handshake.c b/lib/server/server-handshake.c
index 8c68d0ccffd3bfaf70a6426e94eccb6e86844ed8..f5db7e1af6fa3f3671068cd5f20d3f9895a1c4c2 100644
--- a/lib/server/server-handshake.c
+++ b/lib/server/server-handshake.c
@@ -325,7 +325,7 @@ handshake_0405(struct lws_context *context, struct lws *wsi)
 
 		lwsl_parser("issuing resp pkt %d len\n",
 			    lws_ptr_diff(p, response));
-#if defined(DEBUG) && ! defined(LWS_WITH_ESP8266)
+#if defined(DEBUG)
 		fwrite(response, 1,  p - response, stderr);
 #endif
 		n = lws_write(wsi, (unsigned char *)response,
diff --git a/lib/server/server.c b/lib/server/server.c
index 627945e01c318dabaa482ddef1e920a5c7129b41..89a978d328b2a4ef5a3d70fcf8e6c02a353012b8 100644
--- a/lib/server/server.c
+++ b/lib/server/server.c
@@ -28,14 +28,6 @@ const char * const method_names[] = {
 #endif
 	};
 
-#if defined (LWS_WITH_ESP8266)
-#undef memcpy
-void *memcpy(void *dest, const void *src, size_t n)
-{
-	return ets_memcpy(dest, src, n);
-}
-#endif
-
 int
 lws_context_init_server(struct lws_context_creation_info *info,
 			struct lws_vhost *vhost)
@@ -92,11 +84,6 @@ lws_context_init_server(struct lws_context_creation_info *info,
 		sockfd = socket(AF_INET, SOCK_STREAM, 0);
 
 	if (sockfd == -1) {
-#else
-#if defined(LWS_WITH_ESP8266)
-	sockfd = esp8266_create_tcp_listen_socket(vhost);
-	if (!lws_sockfd_valid(sockfd)) {
-#endif
 #endif
 		lwsl_err("ERROR opening socket\n");
 		return 1;
@@ -207,9 +194,6 @@ lws_context_init_server(struct lws_context_creation_info *info,
 	}
 	} /* for each thread able to independently listen */
 #else
-#if defined(LWS_WITH_ESP8266)
-	esp8266_tcp_stream_bind(wsi->desc.sockfd, info->port, wsi);
-#endif
 #endif
 	if (!lws_check_opt(info->options, LWS_SERVER_OPTION_EXPLICIT_VHOSTS)) {
 #ifdef LWS_WITH_UNIX_SOCK
@@ -228,11 +212,6 @@ bail:
 	return 1;
 }
 
-#if defined(LWS_WITH_ESP8266)
-#undef strchr
-#define strchr ets_strchr
-#endif
-
 struct lws_vhost *
 lws_select_vhost(struct lws_context *context, int port, const char *servername)
 {
@@ -388,7 +367,7 @@ lws_http_serve(struct lws *wsi, char *uri, const char *origin,
 	const struct lws_protocol_vhost_options *pvo = m->interpret;
 	struct lws_process_html_args args;
 	const char *mimetype;
-#if !defined(_WIN32_WCE) && !defined(LWS_WITH_ESP8266)
+#if !defined(_WIN32_WCE)
 	const struct lws_plat_file_ops *fops;
 	const char *vpath;
 	lws_fop_flags_t fflags = LWS_O_RDONLY;
@@ -409,7 +388,7 @@ lws_http_serve(struct lws *wsi, char *uri, const char *origin,
 
 	lws_snprintf(path, sizeof(path) - 1, "%s/%s", origin, uri);
 
-#if !defined(_WIN32_WCE) && !defined(LWS_WITH_ESP8266)
+#if !defined(_WIN32_WCE)
 
 	fflags |= lws_vfs_prepare_flags(wsi);
 
@@ -2066,11 +2045,6 @@ lws_adopt_descriptor_vhost(struct lws_vhost *vh, lws_adoption_type type,
 					PENDING_TIMEOUT_ESTABLISH_WITH_SERVER,
 					context->timeout_secs);
 
-#if LWS_POSIX == 0
-#if defined(LWS_WITH_ESP8266)
-		esp8266_tcp_stream_accept(accept_fd, new_wsi);
-#endif
-#endif
 	} else /* file desc */
 		lwsl_debug("%s: new wsi %p, filefd %d\n", __func__, new_wsi,
 			   (int)(lws_intptr_t)fd.filefd);
@@ -2320,14 +2294,12 @@ lws_server_socket_service(struct lws_context *context, struct lws *wsi,
 		 * the POLLOUT), don't let that happen twice in a row...
 		 * next time we see the situation favour POLLOUT
 		 */
-#if !defined(LWS_WITH_ESP8266)
 		if (wsi->favoured_pollin &&
 		    (pollfd->revents & pollfd->events & LWS_POLLOUT)) {
 			lwsl_notice("favouring pollout\n");
 			wsi->favoured_pollin = 0;
 			goto try_pollout;
 		}
-#endif
 
 		/* these states imply we MUST have an ah attached */
 
diff --git a/libwebsockets.dox b/libwebsockets.dox
index b1dfecc6c86e3a1bb9dd82a47c1bc15e70b60d03..002bef1c23e41db1c385487086ff47cfb63003dd 100644
--- a/libwebsockets.dox
+++ b/libwebsockets.dox
@@ -109,7 +109,6 @@ INPUT                  = lib/libwebsockets.h \
 			 ./READMEs/README.lwsws.md \
 			 ./READMEs/README.coding.md \
 			 ./READMEs/README.esp32.md \
-			 ./READMEs/README.esp8266.md \
 			 ./READMEs/README.generic-sessions.md \
 			 ./READMEs/README.generic-table.md \
 			 ./READMEs/README.test-apps.md \
diff --git a/plugins/protocol_dumb_increment.c b/plugins/protocol_dumb_increment.c
index 950c7b723eb59f1df28d180ae7c8d1675aad48a8..c5467b6d705ed9987dfd08fd25ae3195a7b28b5e 100644
--- a/plugins/protocol_dumb_increment.c
+++ b/plugins/protocol_dumb_increment.c
@@ -26,11 +26,7 @@
 
 #include <string.h>
 
-#if defined(LWS_WITH_ESP8266)
 #define DUMB_PERIOD 50
-#else
-#define DUMB_PERIOD 50
-#endif
 
 struct per_vhost_data__dumb_increment {
 	uv_timer_t timeout_watcher;
diff --git a/plugins/protocol_post_demo.c b/plugins/protocol_post_demo.c
index 1e9b21b3f6e722838a4610f8e9539e6810c13622..e1b788b47338b5e25945fe81f5dce7039aa202b6 100644
--- a/plugins/protocol_post_demo.c
+++ b/plugins/protocol_post_demo.c
@@ -41,7 +41,7 @@ struct per_session_data__post_demo {
 
 	char filename[64];
 	long file_length;
-#if !defined(LWS_WITH_ESP8266) && !defined(LWS_WITH_ESP32)
+#if !defined(LWS_WITH_ESP32)
 	lws_filefd_type fd;
 #endif
 };
@@ -66,7 +66,7 @@ file_upload_cb(void *data, const char *name, const char *filename,
 {
 	struct per_session_data__post_demo *pss =
 			(struct per_session_data__post_demo *)data;
-#if !defined(LWS_WITH_ESP8266) && !defined(LWS_WITH_ESP32)
+#if !defined(LWS_WITH_ESP32)
 	int n;
 #endif
 
@@ -76,7 +76,7 @@ file_upload_cb(void *data, const char *name, const char *filename,
 		/* we get the original filename in @filename arg, but for
 		 * simple demo use a fixed name so we don't have to deal with
 		 * attacks  */
-#if !defined(LWS_WITH_ESP8266) && !defined(LWS_WITH_ESP32)
+#if !defined(LWS_WITH_ESP32)
 		pss->fd = (lws_filefd_type)(long long)open("/tmp/post-file",
 			       O_CREAT | O_TRUNC | O_RDWR, 0600);
 #endif
@@ -90,7 +90,7 @@ file_upload_cb(void *data, const char *name, const char *filename,
 			if (pss->file_length > 100000)
 				return 1;
 
-#if !defined(LWS_WITH_ESP8266) && !defined(LWS_WITH_ESP32)
+#if !defined(LWS_WITH_ESP32)
 			n = write((int)(long long)pss->fd, buf, len);
 			lwsl_notice("%s: write %d says %d\n", __func__, len, n);
 #else
@@ -99,7 +99,7 @@ file_upload_cb(void *data, const char *name, const char *filename,
 		}
 		if (state == LWS_UFS_CONTENT)
 			break;
-#if !defined(LWS_WITH_ESP8266) && !defined(LWS_WITH_ESP32)
+#if !defined(LWS_WITH_ESP32)
 		close((int)(long long)pss->fd);
 		pss->fd = LWS_INVALID_FILE;
 #endif