diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c
index 9eb5568e6c934a4090cc27d3425d011f684316a0..118a28a7b6d484458547ee01274b629d70d2fd24 100644
--- a/lib/libwebsockets.c
+++ b/lib/libwebsockets.c
@@ -2954,8 +2954,8 @@ lws_cmdline_option(int argc, const char **argv, const char *val)
 	int n = strlen(val), c = argc;
 
 	while (--c > 0)
-		if (!strncmp(argv[c], val, n) && !*(argv[c] + n)) {
-			if (c != argc - 1)
+		if (!strncmp(argv[c], val, n)) {
+			if (!*(argv[c] + n) && c != argc - 1)
 				return argv[c + 1];
 
 			return argv[c] + n;
diff --git a/minimal-examples/client-server/minimal-ws-proxy/minimal-ws-proxy.c b/minimal-examples/client-server/minimal-ws-proxy/minimal-ws-proxy.c
index 6ca0052b996f2652e7dfd3092213e4382e126862..6c9eaab8565fcc2787e8d3c8ea64d79b02b99250 100644
--- a/minimal-examples/client-server/minimal-ws-proxy/minimal-ws-proxy.c
+++ b/minimal-examples/client-server/minimal-ws-proxy/minimal-ws-proxy.c
@@ -56,30 +56,33 @@ void sigint_handler(int sig)
 	interrupted = 1;
 }
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	struct lws_context_creation_info info;
 	struct lws_context *context;
-	int n = 0;
+	const char *p;
+	int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
+			/* for LLL_ verbosity above NOTICE to be built into lws,
+			 * lws must have been configured and built with
+			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
+			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
+			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
+			/* | LLL_DEBUG */;
 
 	signal(SIGINT, sigint_handler);
 
+	if ((p = lws_cmdline_option(argc, argv, "-d")))
+		logs = atoi(p);
+
+	lws_set_log_level(logs, NULL);
+	lwsl_user("LWS minimal ws proxy | visit http://localhost:7681\n");
+
 	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
 	info.options = LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT;
 	info.port = 7681;
 	info.mounts = &mount;
 	info.protocols = protocols;
 
-	lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
-			/* for LLL_ verbosity above NOTICE to be built into lws,
-			 * lws must have been configured and built with
-			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
-			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
-			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
-			/* | LLL_DEBUG */, NULL);
-
-	lwsl_user("LWS minimal ws proxy | visit http://localhost:7681\n");
-
 	context = lws_create_context(&info);
 	if (!context) {
 		lwsl_err("lws init failed\n");
diff --git a/minimal-examples/http-client/minimal-http-client-certinfo/README.md b/minimal-examples/http-client/minimal-http-client-certinfo/README.md
index e5971c99c758f9f026a105072cb0d4015813da20..ff6ada4b6fec12bfd1ea4b3456ab8769fffe7317 100644
--- a/minimal-examples/http-client/minimal-http-client-certinfo/README.md
+++ b/minimal-examples/http-client/minimal-http-client-certinfo/README.md
@@ -3,14 +3,6 @@
 This demonstrates how to dump information from the peer
 certificate largely independent of the tls backend.
 
-## build
-
-```
- $ cmake . && make
-```
-
-## usage
-
 The application goes to https://warmcat.com and receives the page data.
 
 Before receiving the page it dumps information on the server's cert.
@@ -20,6 +12,20 @@ This works independently of the tls backend being OpenSSL or mbedTLS.
 However the public keys cannot be compared between the two tls
 backends, since they produce different representations.
 
+## build
+
+```
+ $ cmake . && make
+```
+
+## usage
+
+Commandline option|Meaning
+---|---
+-d <loglevel>|Debug verbosity in decimal, eg, -d15
+-l| Connect to https://localhost:7681 and accept selfsigned cert
+--h1|Specify http/1.1 only using ALPN, rejects h2 even if server supports it
+
 ```
  $ ./lws-minimal-http-client-certinfo
 [2018/04/05 21:39:26:5882] USER: LWS minimal http client
diff --git a/minimal-examples/http-client/minimal-http-client-certinfo/minimal-http-client-certinfo.c b/minimal-examples/http-client/minimal-http-client-certinfo/minimal-http-client-certinfo.c
index ed02898cffb0744ad712ddf5dcd6c54db271a9d6..f96b1d5aefe49cde3fbdea3a47c0bc7c7a659007 100644
--- a/minimal-examples/http-client/minimal-http-client-certinfo/minimal-http-client-certinfo.c
+++ b/minimal-examples/http-client/minimal-http-client-certinfo/minimal-http-client-certinfo.c
@@ -16,7 +16,7 @@
 #include <string.h>
 #include <signal.h>
 
-static int interrupted;
+static int interrupted, bad = 1, status;
 static struct lws *client_wsi;
 
 static int
@@ -37,8 +37,8 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason,
 		break;
 
 	case LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP:
-		lwsl_notice("lws_http_client_http_response %d\n",
-				lws_http_client_http_response(wsi));
+		status = lws_http_client_http_response(wsi);
+		lwsl_notice("lws_http_client_http_response %d\n", status);
 
 		if (!lws_tls_peer_cert_info(wsi, LWS_TLS_CERT_INFO_COMMON_NAME,
 					    ci, sizeof(buf) - sizeof(*ci)))
@@ -97,6 +97,8 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason,
 	case LWS_CALLBACK_COMPLETED_CLIENT_HTTP:
 		lwsl_user("LWS_CALLBACK_COMPLETED_CLIENT_HTTP\n");
 		client_wsi = NULL;
+		bad = status != 200;
+		lws_cancel_service(lws_get_context(wsi)); /* abort poll wait */
 		break;
 
 	default:
@@ -122,22 +124,13 @@ sigint_handler(int sig)
 	interrupted = 1;
 }
 
-static int findswitch(int argc, char **argv, const char *val)
-{
-	while (--argc > 0) {
-		if (!strcmp(argv[argc], val))
-			return argc;
-	}
-
-	return 0;
-}
-
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	struct lws_context_creation_info info;
 	struct lws_client_connect_info i;
 	struct lws_context *context;
-	int logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
+	const char *p;
+	int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
 		   /*
 		    * For LLL_ verbosity above NOTICE to be built into lws,
 		    * lws must have been configured and built with
@@ -146,16 +139,14 @@ int main(int argc, char **argv)
 		    * | LLL_INFO   | LLL_PARSER  | LLL_HEADER | LLL_EXT |
 		    *   LLL_CLIENT | LLL_LATENCY | LLL_DEBUG
 		    */ ;
-	int n = 0, m;
 
 	signal(SIGINT, sigint_handler);
-	/* you can set the log level on commandline with, eg, -d 15 */
-	m = findswitch(argc, argv, "-d");
-	if (m && m + 1 < argc)
-		logs = atoi(argv[m + 1]);
+
+	if ((p = lws_cmdline_option(argc, argv, "-d")))
+		logs = atoi(p);
 
 	lws_set_log_level(logs, NULL);
-	lwsl_user("LWS minimal http client\n");
+	lwsl_user("LWS minimal http client [<-d <verbosity>] [-l] [--h1]\n");
 
 	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
 	info.options = LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT;
@@ -178,13 +169,24 @@ int main(int argc, char **argv)
 
 	memset(&i, 0, sizeof i); /* otherwise uninitialized garbage */
 	i.context = context;
-
-	i.port = 443;
-	i.address = "warmcat.com";
+	i.ssl_connection = LCCSCF_USE_SSL;
+
+	if (lws_cmdline_option(argc, argv, "-l")) {
+		i.port = 7681;
+		i.address = "localhost";
+		i.ssl_connection |= LCCSCF_ALLOW_SELFSIGNED;
+	} else {
+		i.port = 443;
+		i.address = "warmcat.com";
+	}
 	i.path = "/";
 	i.host = i.address;
 	i.origin = i.address;
-	i.ssl_connection = /* LCCSCF_NOT_H2 | */ LCCSCF_USE_SSL;
+
+	/* force h1 even if h2 available */
+	if (lws_cmdline_option(argc, argv, "--h1"))
+		i.alpn = "http/1.1";
+
 	i.method = "GET";
 
 	i.protocol = protocols[0].name;
@@ -195,7 +197,7 @@ int main(int argc, char **argv)
 		n = lws_service(context, 1000);
 
 	lws_context_destroy(context);
-	lwsl_user("Completed\n");
+	lwsl_user("Completed: %s\n", bad ? "failed" : "OK");
 
-	return 0;
+	return bad;
 }
diff --git a/minimal-examples/http-client/minimal-http-client-hugeurl/minimal-http-client-hugeurl.c b/minimal-examples/http-client/minimal-http-client-hugeurl/minimal-http-client-hugeurl.c
index d989966bc5edebad1be4ecba8becd4f997e4e846..c50c0d6dde5dd95b51d8868c82b237e551b76ce3 100644
--- a/minimal-examples/http-client/minimal-http-client-hugeurl/minimal-http-client-hugeurl.c
+++ b/minimal-examples/http-client/minimal-http-client-hugeurl/minimal-http-client-hugeurl.c
@@ -8,19 +8,19 @@
  *
  * This demonstrates the a minimal http client using lws.
  *
- * It visits https://warmcat.com/?fakeparam=<2KB> and receives the html page there.  You
- * can dump the page data by changing the #if 0 below.
+ * It visits https://warmcat.com/?fakeparam=<2KB> and receives the html
+ * page there.  You can dump the page data by changing the #if 0 below.
  */
 
 #include <libwebsockets.h>
 #include <string.h>
 #include <signal.h>
 
-static int interrupted;
+static int interrupted, bad = 1, status;
 static struct lws *client_wsi;
 
 static const char * const uri =
-	"/index.html?fakeparam="
+	"/?fakeparam="
 	"00000000000000000000000000000000000000000000000000"
 	"00000000000000000000000000000000000000000000000000"
 	"00000000000000000000000000000000000000000000000000"
@@ -76,6 +76,11 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason,
 		client_wsi = NULL;
 		break;
 
+	case LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP:
+		status = lws_http_client_http_response(wsi);
+		lwsl_user("Connected with server response: %d\n", status);
+		break;
+
 	/* chunks of chunked content, with header removed */
 	case LWS_CALLBACK_RECEIVE_CLIENT_HTTP_READ:
 		lwsl_user("RECEIVE_CLIENT_HTTP_READ: read %d\n", (int)len);
@@ -106,6 +111,8 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason,
 
 	case LWS_CALLBACK_COMPLETED_CLIENT_HTTP:
 		client_wsi = NULL;
+		bad = status != 200;
+		lws_cancel_service(lws_get_context(wsi)); /* abort poll wait */
 		break;
 
 	default:
@@ -131,23 +138,26 @@ sigint_handler(int sig)
 	interrupted = 1;
 }
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	struct lws_context_creation_info info;
 	struct lws_client_connect_info i;
 	struct lws_context *context;
-	int n = 0;
-
-	signal(SIGINT, sigint_handler);
-	lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
+	const char *p;
+	int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
 			/* for LLL_ verbosity above NOTICE to be built into lws,
 			 * lws must have been configured and built with
 			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
 			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
 			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
-			/* | LLL_DEBUG */, NULL);
+			/* | LLL_DEBUG */;
+
+	if ((p = lws_cmdline_option(argc, argv, "-d")))
+		logs = atoi(p);
 
-	lwsl_user("LWS minimal http client hugeurl\n");
+	signal(SIGINT, sigint_handler);
+	lws_set_log_level(logs, NULL);
+	lwsl_user("LWS minimal http client hugeurl [-d <verbosity> [-l]\n");
 
 	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
 	info.options = LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT;
@@ -170,24 +180,30 @@ int main(int argc, char **argv)
 
 	memset(&i, 0, sizeof i); /* otherwise uninitialized garbage */
 	i.context = context;
-
-	i.port = 443;
-	i.address = "warmcat.com";
+	i.ssl_connection = LCCSCF_USE_SSL;
+
+	if (lws_cmdline_option(argc, argv, "-l")) {
+		i.port = 7681;
+		i.address = "localhost";
+		i.ssl_connection |= LCCSCF_ALLOW_SELFSIGNED;
+	} else {
+		i.port = 443;
+		i.address = "warmcat.com";
+	}
 	i.path = uri;
 	i.host = i.address;
 	i.origin = i.address;
-	i.ssl_connection = 1;
 	i.method = "GET";
-
 	i.protocol = protocols[0].name;
 	i.pwsi = &client_wsi;
+
 	lws_client_connect_via_info(&i);
 
 	while (n >= 0 && client_wsi && !interrupted)
 		n = lws_service(context, 1000);
 
 	lws_context_destroy(context);
-	lwsl_user("Completed\n");
+	lwsl_user("Completed: %s\n", bad? "failed": "OK");
 
-	return 0;
+	return bad;
 }
diff --git a/minimal-examples/http-client/minimal-http-client-hugeurl/selftest.sh b/minimal-examples/http-client/minimal-http-client-hugeurl/selftest.sh
new file mode 100755
index 0000000000000000000000000000000000000000..9be3a8a7afde7286a99643a30deedfcf7b555e02
--- /dev/null
+++ b/minimal-examples/http-client/minimal-http-client-hugeurl/selftest.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+#
+# $1: path to minimal example binaries...
+#     if lws is built with -DLWS_WITH_MINIMAL_EXAMPLES=1
+#     that will be ./bin from your build dir
+#
+# $2: path for logs and results.  The results will go
+#     in a subdir named after the directory this script
+#     is in
+
+if [ -z "$1" -o -z "$2" ] ; then
+	echo "required args missing"
+	exit 1
+fi
+
+MYTEST=`echo $0 | sed "s/\/[^\/]*\$//g" |sed "s/.*\///g"`
+mkdir -p $2/$MYTEST
+rm -f $2/$MYTEST/*.log $2/$MYTEST/*.result
+$1/lws-$MYTEST > $2/$MYTEST/1.log 2> $2/$MYTEST/1.log
+echo $? > $2/$MYTEST/1.result
+
+exit 0
+
diff --git a/minimal-examples/http-client/minimal-http-client-multi/minimal-http-client-multi.c b/minimal-examples/http-client/minimal-http-client-multi/minimal-http-client-multi.c
index 7e87780d1505a785254a35bba1bd62434f6ab539..4508fb46e9935255bc38e91f39fb976da7aab119 100644
--- a/minimal-examples/http-client/minimal-http-client-multi/minimal-http-client-multi.c
+++ b/minimal-examples/http-client/minimal-http-client-multi/minimal-http-client-multi.c
@@ -230,7 +230,7 @@ int main(int argc, const char **argv)
 	if (!staggered)
 		/*
 		 * just pile on all the connections at once, testing the
-		 * pipeline queueing before the first is connected
+		 * pipeline queuing before the first is connected
 		 */
 		for (m = 0; m < (int)LWS_ARRAY_SIZE(client_wsi); m++)
 			lws_try_client_connection(&i, m);
@@ -242,7 +242,7 @@ int main(int argc, const char **argv)
 		if (staggered) {
 			/*
 			 * open the connections at 100ms intervals, with the
-			 * last one being after 1s, testing both queueing, and
+			 * last one being after 1s, testing both queuing, and
 			 * direct H2 stream addition stability
 			 */
 			if (us() > next && m < (int)LWS_ARRAY_SIZE(client_wsi)) {
diff --git a/minimal-examples/http-client/minimal-http-client-post/minimal-http-client-post.c b/minimal-examples/http-client/minimal-http-client-post/minimal-http-client-post.c
index 66e578b2e3d55b960d5ca18441662f83607a3370..d2406892dd583f56c664d9385af898bbdf2679e8 100644
--- a/minimal-examples/http-client/minimal-http-client-post/minimal-http-client-post.c
+++ b/minimal-examples/http-client/minimal-http-client-post/minimal-http-client-post.c
@@ -17,7 +17,7 @@
 #include <string.h>
 #include <signal.h>
 
-static int interrupted;
+static int interrupted, bad = 1, status;
 static struct lws *client_wsi;
 
 struct pss {
@@ -48,8 +48,8 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason,
 	/* ...callbacks related to receiving the result... */
 
 	case LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP:
-		lwsl_user("LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP: response %d\n",
-				lws_http_client_http_response(wsi));
+		status = lws_http_client_http_response(wsi);
+		lwsl_user("Connected with server response: %d\n", status);
 		break;
 
 	case LWS_CALLBACK_RECEIVE_CLIENT_HTTP_READ:
@@ -67,6 +67,7 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason,
 	case LWS_CALLBACK_COMPLETED_CLIENT_HTTP:
 		lwsl_user("LWS_CALLBACK_COMPLETED_CLIENT_HTTP\n");
 		client_wsi = NULL;
+		bad = status != 200;
 		break;
 
 	/* ...callbacks related to generating the POST... */
@@ -182,23 +183,29 @@ sigint_handler(int sig)
 	interrupted = 1;
 }
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	struct lws_context_creation_info info;
 	struct lws_client_connect_info i;
 	struct lws_context *context;
-	int n = 0;
+	const char *p;
+	int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
+		   /*
+		    * For LLL_ verbosity above NOTICE to be built into lws,
+		    * lws must have been configured and built with
+		    * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE
+		    *
+		    * | LLL_INFO   | LLL_PARSER  | LLL_HEADER | LLL_EXT |
+		    *   LLL_CLIENT | LLL_LATENCY | LLL_DEBUG
+		    */ ;
 
 	signal(SIGINT, sigint_handler);
-	lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
-			/* for LLL_ verbosity above NOTICE to be built into lws,
-			 * lws must have been configured and built with
-			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
-			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
-			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
-			/* | LLL_DEBUG */, NULL);
 
-	lwsl_user("LWS minimal http client - POST\n");
+	if ((p = lws_cmdline_option(argc, argv, "-d")))
+		logs = atoi(p);
+
+	lws_set_log_level(logs, NULL);
+	lwsl_user("LWS minimal http client - POST [-d<verbosity>] [-l] [--h1]\n");
 
 	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
 	info.options = LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT;
@@ -221,15 +228,27 @@ int main(int argc, char **argv)
 
 	memset(&i, 0, sizeof i); /* otherwise uninitialized garbage */
 	i.context = context;
+	i.ssl_connection = LCCSCF_USE_SSL;
+
+	if (lws_cmdline_option(argc, argv, "-l")) {
+		i.port = 7681;
+		i.address = "localhost";
+		i.ssl_connection |= LCCSCF_ALLOW_SELFSIGNED;
+		i.path = "/formtest";
+	} else {
+		i.port = 443;
+		i.address = "libwebsockets.org";
+		i.path = "/testserver/formtest";
+	}
 
-	i.port = 443;
-	i.address = "libwebsockets.org";
-	i.path = "/testserver/formtest";
-	i.ssl_connection = /* LCCSCF_NOT_H2 | */ LCCSCF_USE_SSL;
 	i.host = i.address;
 	i.origin = i.address;
 	i.method = "POST";
 
+	/* force h1 even if h2 available */
+	if (lws_cmdline_option(argc, argv, "--h1"))
+		i.alpn = "http/1.1";
+
 	i.protocol = protocols[0].name;
 	i.pwsi = &client_wsi;
 	lws_client_connect_via_info(&i);
@@ -238,7 +257,7 @@ int main(int argc, char **argv)
 		n = lws_service(context, 1000);
 
 	lws_context_destroy(context);
-	lwsl_user("Completed\n");
+	lwsl_user("Completed: %s\n", bad ? "failed" : "OK");
 
-	return 0;
+	return bad;
 }
diff --git a/minimal-examples/http-client/minimal-http-client/README.md b/minimal-examples/http-client/minimal-http-client/README.md
index 9d2795570818c8162e000c59cff2155cf1b378bd..a3ac8d6820597abc8aa9407aa4ec5a5b908ac84a 100644
--- a/minimal-examples/http-client/minimal-http-client/README.md
+++ b/minimal-examples/http-client/minimal-http-client/README.md
@@ -1,5 +1,8 @@
 # lws minimal http client
 
+The application goes to either https://warmcat.com or
+https://localhost:7681 (with `-l` option) and receives the page data.
+
 ## build
 
 ```
@@ -8,7 +11,11 @@
 
 ## usage
 
-The application goes to https://warmcat.com and receives the page data.
+Commandline option|Meaning
+---|---
+-d <loglevel>|Debug verbosity in decimal, eg, -d15
+-l| Connect to https://localhost:7681 and accept selfsigned cert
+--h1|Specify http/1.1 only using ALPN, rejects h2 even if server supports it
 
 ```
  $ ./lws-minimal-http-client
diff --git a/minimal-examples/http-client/minimal-http-client/minimal-http-client.c b/minimal-examples/http-client/minimal-http-client/minimal-http-client.c
index 3056283339d366c07c90017fb9034b8865c9e024..a0efb6477354555a8c6f1060b2a2b81989827d76 100644
--- a/minimal-examples/http-client/minimal-http-client/minimal-http-client.c
+++ b/minimal-examples/http-client/minimal-http-client/minimal-http-client.c
@@ -16,7 +16,7 @@
 #include <string.h>
 #include <signal.h>
 
-static int interrupted;
+static int interrupted, bad = 1, status;
 static struct lws *client_wsi;
 
 static int
@@ -32,6 +32,11 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason,
 		client_wsi = NULL;
 		break;
 
+	case LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP:
+		status = lws_http_client_http_response(wsi);
+		lwsl_user("Connected with server response: %d\n", status);
+		break;
+
 	/* chunks of chunked content, with header removed */
 	case LWS_CALLBACK_RECEIVE_CLIENT_HTTP_READ:
 		lwsl_user("RECEIVE_CLIENT_HTTP_READ: read %d\n", (int)len);
@@ -63,6 +68,8 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason,
 	case LWS_CALLBACK_COMPLETED_CLIENT_HTTP:
 		lwsl_user("LWS_CALLBACK_COMPLETED_CLIENT_HTTP\n");
 		client_wsi = NULL;
+		bad = status != 200;
+		lws_cancel_service(lws_get_context(wsi)); /* abort poll wait */
 		break;
 
 	default:
@@ -88,22 +95,13 @@ sigint_handler(int sig)
 	interrupted = 1;
 }
 
-static int findswitch(int argc, char **argv, const char *val)
-{
-	while (--argc > 0) {
-		if (!strcmp(argv[argc], val))
-			return argc;
-	}
-
-	return 0;
-}
-
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	struct lws_context_creation_info info;
 	struct lws_client_connect_info i;
 	struct lws_context *context;
-	int logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
+	const char *p;
+	int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
 		   /*
 		    * For LLL_ verbosity above NOTICE to be built into lws,
 		    * lws must have been configured and built with
@@ -112,16 +110,14 @@ int main(int argc, char **argv)
 		    * | LLL_INFO   | LLL_PARSER  | LLL_HEADER | LLL_EXT |
 		    *   LLL_CLIENT | LLL_LATENCY | LLL_DEBUG
 		    */ ;
-	int n = 0, m;
 
 	signal(SIGINT, sigint_handler);
-	/* you can set the log level on commandline with, eg, -d 15 */
-	m = findswitch(argc, argv, "-d");
-	if (m && m + 1 < argc)
-		logs = atoi(argv[m + 1]);
+
+	if ((p = lws_cmdline_option(argc, argv, "-d")))
+		logs = atoi(p);
 
 	lws_set_log_level(logs, NULL);
-	lwsl_user("LWS minimal http client\n");
+	lwsl_user("LWS minimal http client [-d<verbosity>] [-l] [--h1]\n");
 
 	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
 	info.options = LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT;
@@ -144,13 +140,23 @@ int main(int argc, char **argv)
 
 	memset(&i, 0, sizeof i); /* otherwise uninitialized garbage */
 	i.context = context;
+	i.ssl_connection = LCCSCF_USE_SSL;
+
+	if (lws_cmdline_option(argc, argv, "-l")) {
+		i.port = 7681;
+		i.address = "localhost";
+		i.ssl_connection |= LCCSCF_ALLOW_SELFSIGNED;
+	} else {
+		i.port = 443;
+		i.address = "warmcat.com";
+	}
+
+	if (lws_cmdline_option(argc, argv, "--h1"))
+		i.alpn = "http/1.1";
 
-	i.port = 443;
-	i.address = "warmcat.com";
 	i.path = "/";
 	i.host = i.address;
 	i.origin = i.address;
-	i.ssl_connection = /* LCCSCF_NOT_H2 | */ LCCSCF_USE_SSL;
 	i.method = "GET";
 
 	i.protocol = protocols[0].name;
@@ -161,7 +167,7 @@ int main(int argc, char **argv)
 		n = lws_service(context, 1000);
 
 	lws_context_destroy(context);
-	lwsl_user("Completed\n");
+	lwsl_user("Completed: %s\n", bad ? "failed" : "OK");
 
-	return 0;
+	return bad;
 }
diff --git a/minimal-examples/http-client/minimal-http-client/selftest.sh b/minimal-examples/http-client/minimal-http-client/selftest.sh
new file mode 100755
index 0000000000000000000000000000000000000000..9be3a8a7afde7286a99643a30deedfcf7b555e02
--- /dev/null
+++ b/minimal-examples/http-client/minimal-http-client/selftest.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+#
+# $1: path to minimal example binaries...
+#     if lws is built with -DLWS_WITH_MINIMAL_EXAMPLES=1
+#     that will be ./bin from your build dir
+#
+# $2: path for logs and results.  The results will go
+#     in a subdir named after the directory this script
+#     is in
+
+if [ -z "$1" -o -z "$2" ] ; then
+	echo "required args missing"
+	exit 1
+fi
+
+MYTEST=`echo $0 | sed "s/\/[^\/]*\$//g" |sed "s/.*\///g"`
+mkdir -p $2/$MYTEST
+rm -f $2/$MYTEST/*.log $2/$MYTEST/*.result
+$1/lws-$MYTEST > $2/$MYTEST/1.log 2> $2/$MYTEST/1.log
+echo $? > $2/$MYTEST/1.result
+
+exit 0
+
diff --git a/minimal-examples/http-server/minimal-http-server-dynamic/minimal-http-server-dynamic.c b/minimal-examples/http-server/minimal-http-server-dynamic/minimal-http-server-dynamic.c
index 088fab833270d1768e1a1e34d65f61f0e3bfdfec..2b7fa4cc63dcc75397c4aeedf811322f9bc93e80 100644
--- a/minimal-examples/http-server/minimal-http-server-dynamic/minimal-http-server-dynamic.c
+++ b/minimal-examples/http-server/minimal-http-server-dynamic/minimal-http-server-dynamic.c
@@ -151,29 +151,32 @@ void sigint_handler(int sig)
 	interrupted = 1;
 }
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	struct lws_context_creation_info info;
 	struct lws_context *context;
-	int n = 0;
-
-	signal(SIGINT, sigint_handler);
-
-	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
-	info.port = 7681;
-	info.protocols = protocols;
-	info.mounts = &mount;
-
-	lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
+	const char *p;
+	int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
 			/* for LLL_ verbosity above NOTICE to be built into lws,
 			 * lws must have been configured and built with
 			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
 			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
 			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
-			/* | LLL_DEBUG */, NULL);
+			/* | LLL_DEBUG */;
 
+	signal(SIGINT, sigint_handler);
+
+	if ((p = lws_cmdline_option(argc, argv, "-d")))
+		logs = atoi(p);
+
+	lws_set_log_level(logs, NULL);
 	lwsl_user("LWS minimal http server dynamic | visit http://localhost:7681\n");
 
+	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
+	info.port = 7681;
+	info.protocols = protocols;
+	info.mounts = &mount;
+
 	context = lws_create_context(&info);
 	if (!context) {
 		lwsl_err("lws init failed\n");
diff --git a/minimal-examples/http-server/minimal-http-server-form-get/minimal-http-server-form-get.c b/minimal-examples/http-server/minimal-http-server-form-get/minimal-http-server-form-get.c
index 64cb1aac11b5c7cd324220f9383d3d875372b39b..4a5a4a4068166b8c8c740a768615bd70fbc6df11 100644
--- a/minimal-examples/http-server/minimal-http-server-form-get/minimal-http-server-form-get.c
+++ b/minimal-examples/http-server/minimal-http-server-form-get/minimal-http-server-form-get.c
@@ -115,29 +115,32 @@ void sigint_handler(int sig)
 	interrupted = 1;
 }
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	struct lws_context_creation_info info;
 	struct lws_context *context;
-	int n = 0;
-
-	signal(SIGINT, sigint_handler);
-
-	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
-	info.port = 7681;
-	info.protocols = protocols;
-	info.mounts = &mount;
-
-	lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
+	const char *p;
+	int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
 			/* for LLL_ verbosity above NOTICE to be built into lws,
 			 * lws must have been configured and built with
 			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
 			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
 			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
-			/* | LLL_DEBUG */, NULL);
+			/* | LLL_DEBUG */;
 
+	signal(SIGINT, sigint_handler);
+
+	if ((p = lws_cmdline_option(argc, argv, "-d")))
+		logs = atoi(p);
+
+	lws_set_log_level(logs, NULL);
 	lwsl_user("LWS minimal http server GET | visit http://localhost:7681\n");
 
+	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
+	info.port = 7681;
+	info.protocols = protocols;
+	info.mounts = &mount;
+
 	context = lws_create_context(&info);
 	if (!context) {
 		lwsl_err("lws init failed\n");
diff --git a/minimal-examples/http-server/minimal-http-server-form-post-file/minimal-http-server-form-post-file.c b/minimal-examples/http-server/minimal-http-server-form-post-file/minimal-http-server-form-post-file.c
index d335af7f9d99529168c2c588061579550cfae4e7..e974821b4e84069c4b269596b7eb8b65b890a0fe 100644
--- a/minimal-examples/http-server/minimal-http-server-form-post-file/minimal-http-server-form-post-file.c
+++ b/minimal-examples/http-server/minimal-http-server-form-post-file/minimal-http-server-form-post-file.c
@@ -225,29 +225,32 @@ void sigint_handler(int sig)
 	interrupted = 1;
 }
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	struct lws_context_creation_info info;
 	struct lws_context *context;
-	int n = 0;
-
-	signal(SIGINT, sigint_handler);
-
-	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
-	info.port = 7681;
-	info.protocols = protocols;
-	info.mounts = &mount;
-
-	lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
+	const char *p;
+	int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
 			/* for LLL_ verbosity above NOTICE to be built into lws,
 			 * lws must have been configured and built with
 			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
 			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
 			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
-			/* | LLL_DEBUG */, NULL);
+			/* | LLL_DEBUG */;
 
+	signal(SIGINT, sigint_handler);
+
+	if ((p = lws_cmdline_option(argc, argv, "-d")))
+		logs = atoi(p);
+
+	lws_set_log_level(logs, NULL);
 	lwsl_user("LWS minimal http server POST file | visit http://localhost:7681\n");
 
+	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
+	info.port = 7681;
+	info.protocols = protocols;
+	info.mounts = &mount;
+
 	context = lws_create_context(&info);
 	if (!context) {
 		lwsl_err("lws init failed\n");
diff --git a/minimal-examples/http-server/minimal-http-server-form-post/minimal-http-server-form-post.c b/minimal-examples/http-server/minimal-http-server-form-post/minimal-http-server-form-post.c
index ea5760e7564099dbc02e9a212323851dbde23e8b..10c73e9037b9d7fa57ccd1f3936346c63e2f36ce 100644
--- a/minimal-examples/http-server/minimal-http-server-form-post/minimal-http-server-form-post.c
+++ b/minimal-examples/http-server/minimal-http-server-form-post/minimal-http-server-form-post.c
@@ -169,29 +169,32 @@ void sigint_handler(int sig)
 	interrupted = 1;
 }
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	struct lws_context_creation_info info;
 	struct lws_context *context;
-	int n = 0;
-
-	signal(SIGINT, sigint_handler);
-
-	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
-	info.port = 7681;
-	info.protocols = protocols;
-	info.mounts = &mount;
-
-	lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
+	const char *p;
+	int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
 			/* for LLL_ verbosity above NOTICE to be built into lws,
 			 * lws must have been configured and built with
 			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
 			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
 			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
-			/* | LLL_DEBUG */, NULL);
+			/* | LLL_DEBUG */;
 
+	signal(SIGINT, sigint_handler);
+
+	if ((p = lws_cmdline_option(argc, argv, "-d")))
+		logs = atoi(p);
+
+	lws_set_log_level(logs, NULL);
 	lwsl_user("LWS minimal http server POST | visit http://localhost:7681\n");
 
+	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
+	info.port = 7681;
+	info.protocols = protocols;
+	info.mounts = &mount;
+
 	context = lws_create_context(&info);
 	if (!context) {
 		lwsl_err("lws init failed\n");
diff --git a/minimal-examples/http-server/minimal-http-server-libuv-foreign/minimal-http-server-libuv-foreign.c b/minimal-examples/http-server/minimal-http-server-libuv-foreign/minimal-http-server-libuv-foreign.c
index 3da9d0cbb69cded85ff691b43ee31890b852ae86..b27763b54dc89d50028988179bbfceef3736ec8b 100644
--- a/minimal-examples/http-server/minimal-http-server-libuv-foreign/minimal-http-server-libuv-foreign.c
+++ b/minimal-examples/http-server/minimal-http-server-libuv-foreign/minimal-http-server-libuv-foreign.c
@@ -75,29 +75,33 @@ static void lws_uv_walk_cb(uv_handle_t *handle, void *arg)
 	uv_close(handle, lws_uv_close_cb);
 }
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	struct lws_context_creation_info info;
 	uv_timer_t timer_outer;
 	uv_loop_t loop;
-
-	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
-	info.port = 7681;
-	info.mounts = &mount;
-	info.error_document_404 = "/404.html";
-	info.options = LWS_SERVER_OPTION_LIBUV;
-
-	lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
+	const char *p;
+	int logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
 			/* for LLL_ verbosity above NOTICE to be built into lws,
 			 * lws must have been configured and built with
 			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
 			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
 			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
-			/* | LLL_DEBUG */, NULL);
+			/* | LLL_DEBUG */;
 
+	if ((p = lws_cmdline_option(argc, argv, "-d")))
+		logs = atoi(p);
+
+	lws_set_log_level(logs, NULL);
 	lwsl_user("LWS minimal http server libuv + foreign loop |"
 		  " visit http://localhost:7681\n");
 
+	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
+	info.port = 7681;
+	info.mounts = &mount;
+	info.error_document_404 = "/404.html";
+	info.options = LWS_SERVER_OPTION_LIBUV;
+
 	uv_loop_init(&loop);
 
 	uv_timer_init(&loop, &timer_outer);
diff --git a/minimal-examples/http-server/minimal-http-server-libuv/minimal-http-server.c b/minimal-examples/http-server/minimal-http-server-libuv/minimal-http-server.c
index 81a2d1f1d2758a4c97129c1bbba81530cddff91e..f93e651a506e604a0a6539b673e635ca21e2d989 100644
--- a/minimal-examples/http-server/minimal-http-server-libuv/minimal-http-server.c
+++ b/minimal-examples/http-server/minimal-http-server-libuv/minimal-http-server.c
@@ -55,26 +55,30 @@ void signal_cb(uv_signal_t *watcher, int signum)
 	lws_libuv_stop(context);
 }
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	struct lws_context_creation_info info;
-
-	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
-	info.port = 7681;
-	info.mounts = &mount;
-	info.error_document_404 = "/404.html";
-	info.options = LWS_SERVER_OPTION_LIBUV;
-
-	lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
+	const char *p;
+	int logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
 			/* for LLL_ verbosity above NOTICE to be built into lws,
 			 * lws must have been configured and built with
 			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
 			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
 			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
-			/* | LLL_DEBUG */, NULL);
+			/* | LLL_DEBUG */;
 
+	if ((p = lws_cmdline_option(argc, argv, "-d")))
+		logs = atoi(p);
+
+	lws_set_log_level(logs, NULL);
 	lwsl_user("LWS minimal http server libuv | visit http://localhost:7681\n");
 
+	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
+	info.port = 7681;
+	info.mounts = &mount;
+	info.error_document_404 = "/404.html";
+	info.options = LWS_SERVER_OPTION_LIBUV;
+
 	context = lws_create_context(&info);
 	if (!context) {
 		lwsl_err("lws init failed\n");
diff --git a/minimal-examples/http-server/minimal-http-server-multivhost/minimal-http-server.c b/minimal-examples/http-server/minimal-http-server-multivhost/minimal-http-server.c
index 3507ede7c3d9b13a2317870f1c59295c96ae0e15..57e07541bca8d8dce651646623b62cbd2e0f8c66 100644
--- a/minimal-examples/http-server/minimal-http-server-multivhost/minimal-http-server.c
+++ b/minimal-examples/http-server/minimal-http-server-multivhost/minimal-http-server.c
@@ -80,27 +80,30 @@ void sigint_handler(int sig)
 	interrupted = 1;
 }
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	struct lws_context_creation_info info;
 	struct lws_context *context;
-	int n = 0;
-
-	signal(SIGINT, sigint_handler);
-
-	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
-	info.options = LWS_SERVER_OPTION_EXPLICIT_VHOSTS;
-
-	lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
+	const char *p;
+	int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
 			/* for LLL_ verbosity above NOTICE to be built into lws,
 			 * lws must have been configured and built with
 			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
 			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
 			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
-			/* | LLL_DEBUG */, NULL);
+			/* | LLL_DEBUG */;
 
+	if ((p = lws_cmdline_option(argc, argv, "-d")))
+		logs = atoi(p);
+
+	lws_set_log_level(logs, NULL);
 	lwsl_user("LWS minimal http server-multivhost | visit http://localhost:7681 / 7682\n");
 
+	signal(SIGINT, sigint_handler);
+
+	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
+	info.options = LWS_SERVER_OPTION_EXPLICIT_VHOSTS;
+
 	/*
 	 * Because of LWS_SERVER_OPTION_EXPLICIT_VHOSTS, this only creates
 	 * the context and no longer creates a default vhost
diff --git a/minimal-examples/http-server/minimal-http-server-smp/minimal-http-server-smp.c b/minimal-examples/http-server/minimal-http-server-smp/minimal-http-server-smp.c
index d38c5d48ca7907b837a8ab1d839386c81782d26e..fcd008b5e458815b41e6acb8688720630679cfad 100644
--- a/minimal-examples/http-server/minimal-http-server-smp/minimal-http-server-smp.c
+++ b/minimal-examples/http-server/minimal-http-server-smp/minimal-http-server-smp.c
@@ -64,12 +64,25 @@ void sigint_handler(int sig)
 	lws_cancel_service(context);
 }
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	pthread_t pthread_service[COUNT_THREADS];
 	struct lws_context_creation_info info;
 	void *retval;
-	int n = 0;
+	const char *p;
+	int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
+			/* for LLL_ verbosity above NOTICE to be built into lws,
+			 * lws must have been configured and built with
+			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
+			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
+			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
+			/* | LLL_DEBUG */;
+
+	if ((p = lws_cmdline_option(argc, argv, "-d")))
+		logs = atoi(p);
+
+	lws_set_log_level(logs, NULL);
+	lwsl_user("LWS minimal http server SMP | visit http://127.0.0.1:7681\n");
 
 	signal(SIGINT, sigint_handler);
 
@@ -79,16 +92,6 @@ int main(int argc, char **argv)
 	// info.max_http_header_pool = 10;
 	info.count_threads = COUNT_THREADS;
 
-	lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
-			/* for LLL_ verbosity above NOTICE to be built into lws,
-			 * lws must have been configured and built with
-			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
-			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
-			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
-			/* | LLL_DEBUG */, NULL);
-
-	lwsl_user("LWS minimal http server SMP | visit http://127.0.0.1:7681\n");
-
 	context = lws_create_context(&info);
 	if (!context) {
 		lwsl_err("lws init failed\n");
diff --git a/minimal-examples/http-server/minimal-http-server-tls/minimal-http-server-tls.c b/minimal-examples/http-server/minimal-http-server-tls/minimal-http-server-tls.c
index 96dc19c786e2c683793406f1da6c847bdc0da47e..7af4db8cba6503d82ec817f4204aec58a708ad5c 100644
--- a/minimal-examples/http-server/minimal-http-server-tls/minimal-http-server-tls.c
+++ b/minimal-examples/http-server/minimal-http-server-tls/minimal-http-server-tls.c
@@ -47,11 +47,24 @@ void sigint_handler(int sig)
 	interrupted = 1;
 }
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	struct lws_context_creation_info info;
 	struct lws_context *context;
-	int n = 0;
+	const char *p;
+	int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
+			/* for LLL_ verbosity above NOTICE to be built into lws,
+			 * lws must have been configured and built with
+			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
+			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
+			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
+			/* | LLL_DEBUG */;
+
+	if ((p = lws_cmdline_option(argc, argv, "-d")))
+		logs = atoi(p);
+
+	lws_set_log_level(logs, NULL);
+	lwsl_user("LWS minimal http server TLS | visit https://localhost:7681\n");
 
 	signal(SIGINT, sigint_handler);
 
@@ -64,16 +77,6 @@ int main(int argc, char **argv)
 	info.ssl_cert_filepath = "localhost-100y.cert";
 	info.ssl_private_key_filepath = "localhost-100y.key";
 
-	lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
-			/* for LLL_ verbosity above NOTICE to be built into lws,
-			 * lws must have been configured and built with
-			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
-			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
-			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
-			/* | LLL_DEBUG */, NULL);
-
-	lwsl_user("LWS minimal http server TLS | visit https://localhost:7681\n");
-
 	context = lws_create_context(&info);
 	if (!context) {
 		lwsl_err("lws init failed\n");
diff --git a/minimal-examples/http-server/minimal-http-server/minimal-http-server.c b/minimal-examples/http-server/minimal-http-server/minimal-http-server.c
index 5ad28fd5111493dbdc7caaa343b27fd4d9782ad7..20b59e8b69ea8b70040141d74b3c484f7436f16a 100644
--- a/minimal-examples/http-server/minimal-http-server/minimal-http-server.c
+++ b/minimal-examples/http-server/minimal-http-server/minimal-http-server.c
@@ -22,7 +22,7 @@ static int interrupted;
 static const struct lws_http_mount mount = {
 	/* .mount_next */		NULL,		/* linked-list "next" */
 	/* .mountpoint */		"/",		/* mountpoint URL */
-	/* .origin */			"./mount-origin",		/* serve from dir */
+	/* .origin */			"./mount-origin", /* serve from dir */
 	/* .def */			"index.html",	/* default filename */
 	/* .protocol */			NULL,
 	/* .cgienv */			NULL,
@@ -44,29 +44,32 @@ void sigint_handler(int sig)
 	interrupted = 1;
 }
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	struct lws_context_creation_info info;
 	struct lws_context *context;
-	int n = 0;
-
-	signal(SIGINT, sigint_handler);
-
-	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
-	info.port = 7681;
-	info.mounts = &mount;
-	info.error_document_404 = "/404.html";
-
-	lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
+	const char *p;
+	int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
 			/* for LLL_ verbosity above NOTICE to be built into lws,
 			 * lws must have been configured and built with
 			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
 			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
 			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
-			/* | LLL_INFO */ /* | LLL_DEBUG */, NULL);
+			/* | LLL_DEBUG */;
 
+	signal(SIGINT, sigint_handler);
+
+	if ((p = lws_cmdline_option(argc, argv, "-d")))
+		logs = atoi(p);
+
+	lws_set_log_level(logs, NULL);
 	lwsl_user("LWS minimal http server | visit http://localhost:7681\n");
 
+	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
+	info.port = 7681;
+	info.mounts = &mount;
+	info.error_document_404 = "/404.html";
+
 	context = lws_create_context(&info);
 	if (!context) {
 		lwsl_err("lws init failed\n");
diff --git a/minimal-examples/raw/minimal-raw-adopt-tcp/minimal-raw-adopt-tcp.c b/minimal-examples/raw/minimal-raw-adopt-tcp/minimal-raw-adopt-tcp.c
index b975662acd89ece6af600eb9705ad7fb7b7e3ddb..6344fd6d0e8b621a9d0532b54ed9e8b02902ca74 100644
--- a/minimal-examples/raw/minimal-raw-adopt-tcp/minimal-raw-adopt-tcp.c
+++ b/minimal-examples/raw/minimal-raw-adopt-tcp/minimal-raw-adopt-tcp.c
@@ -83,28 +83,33 @@ void sigint_handler(int sig)
 	interrupted = 1;
 }
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	struct lws_context_creation_info info;
 	struct lws_context *context;
 	lws_sock_file_fd_type sock;
 	struct addrinfo h, *r, *rp;
 	struct lws_vhost *vhost;
-	int n = 0;
-
-	lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
+	const char *p;
+	int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
 			/* for LLL_ verbosity above NOTICE to be built into lws,
 			 * lws must have been configured and built with
 			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
 			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
 			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
-			/* | LLL_DEBUG */, NULL);
+			/* | LLL_DEBUG */;
 
-	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
-	info.options = LWS_SERVER_OPTION_EXPLICIT_VHOSTS;
+	signal(SIGINT, sigint_handler);
 
+	if ((p = lws_cmdline_option(argc, argv, "-d")))
+		logs = atoi(p);
+
+	lws_set_log_level(logs, NULL);
 	lwsl_user("LWS minimal raw adopt tcp\n");
 
+	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
+	info.options = LWS_SERVER_OPTION_EXPLICIT_VHOSTS;
+
 	context = lws_create_context(&info);
 	if (!context) {
 		lwsl_err("lws init failed\n");
diff --git a/minimal-examples/raw/minimal-raw-adopt-udp/minimal-raw-adopt-udp.c b/minimal-examples/raw/minimal-raw-adopt-udp/minimal-raw-adopt-udp.c
index d67d8da8376799b8fd2f68772329524f3843ec6c..23a9c5a6a53fb86322d0a965a49929a125b78378 100644
--- a/minimal-examples/raw/minimal-raw-adopt-udp/minimal-raw-adopt-udp.c
+++ b/minimal-examples/raw/minimal-raw-adopt-udp/minimal-raw-adopt-udp.c
@@ -120,27 +120,30 @@ void sigint_handler(int sig)
 	interrupted = 1;
 }
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	struct lws_context_creation_info info;
 	struct lws_context *context;
 	struct lws_vhost *vhost;
-	int n = 0;
-
-	lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
+	const char *p;
+	int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
 			/* for LLL_ verbosity above NOTICE to be built into lws,
 			 * lws must have been configured and built with
 			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
 			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
 			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
-			/* | LLL_DEBUG */, NULL);
+			/* | LLL_DEBUG */;
 
-	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
-	info.options = LWS_SERVER_OPTION_EXPLICIT_VHOSTS;
+	signal(SIGINT, sigint_handler);
 
+	if ((p = lws_cmdline_option(argc, argv, "-d")))
+		logs = atoi(p);
+
+	lws_set_log_level(logs, NULL);
 	lwsl_user("LWS minimal raw adopt udp | nc -u 127.0.0.1 7681\n");
 
-	signal(SIGINT, sigint_handler);
+	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
+	info.options = LWS_SERVER_OPTION_EXPLICIT_VHOSTS;
 
 	context = lws_create_context(&info);
 	if (!context) {
diff --git a/minimal-examples/raw/minimal-raw-file/minimal-raw-file.c b/minimal-examples/raw/minimal-raw-file/minimal-raw-file.c
index 98199572b4c7a8c7d6cc8a8970c62facaa34b3f3..74b0c422e0b43f26407e4eb8e7b021741e4bc3ca 100644
--- a/minimal-examples/raw/minimal-raw-file/minimal-raw-file.c
+++ b/minimal-examples/raw/minimal-raw-file/minimal-raw-file.c
@@ -106,26 +106,25 @@ void sigint_handler(int sig)
 	interrupted = 1;
 }
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	struct lws_context_creation_info info;
 	struct lws_context *context;
-	int n = 0;
-
-	signal(SIGINT, sigint_handler);
-
-	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
-	info.port = CONTEXT_PORT_NO_LISTEN_SERVER; /* no listen socket for demo */
-	info.protocols = protocols;
-
-	lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
+	const char *p;
+	int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
 			/* for LLL_ verbosity above NOTICE to be built into lws,
 			 * lws must have been configured and built with
 			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
 			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
 			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
-			/* | LLL_DEBUG */, NULL);
+			/* | LLL_DEBUG */;
+
+	signal(SIGINT, sigint_handler);
+
+	if ((p = lws_cmdline_option(argc, argv, "-d")))
+		logs = atoi(p);
 
+	lws_set_log_level(logs, NULL);
 	lwsl_user("LWS minimal raw file\n");
 	if (argc < 2) {
 		lwsl_user("Usage: %s <file to monitor>  "
@@ -135,6 +134,12 @@ int main(int argc, char **argv)
 		return 1;
 	}
 
+	signal(SIGINT, sigint_handler);
+
+	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
+	info.port = CONTEXT_PORT_NO_LISTEN_SERVER; /* no listen socket for demo */
+	info.protocols = protocols;
+
 	lws_strncpy(filepath, argv[1], sizeof(filepath));
 
 	context = lws_create_context(&info);
diff --git a/minimal-examples/raw/minimal-raw-vhost/minimal-raw-vhost.c b/minimal-examples/raw/minimal-raw-vhost/minimal-raw-vhost.c
index 7989c2c4c140a6055c73f20ec378a6134829cf04..05043d0869f10feae5feb6934f15038231f46ac0 100644
--- a/minimal-examples/raw/minimal-raw-vhost/minimal-raw-vhost.c
+++ b/minimal-examples/raw/minimal-raw-vhost/minimal-raw-vhost.c
@@ -110,29 +110,32 @@ void sigint_handler(int sig)
 	interrupted = 1;
 }
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	struct lws_context_creation_info info;
 	struct lws_context *context;
-	int n = 0;
-
-	signal(SIGINT, sigint_handler);
-
-	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
-	info.port = 7681;
-	info.protocols = protocols;
-	info.options = LWS_SERVER_OPTION_ONLY_RAW; /* vhost accepts RAW */
-
-	lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
+	const char *p;
+	int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
 			/* for LLL_ verbosity above NOTICE to be built into lws,
 			 * lws must have been configured and built with
 			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
 			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
 			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
-			/* | LLL_DEBUG */, NULL);
+			/* | LLL_DEBUG */;
 
+	signal(SIGINT, sigint_handler);
+
+	if ((p = lws_cmdline_option(argc, argv, "-d")))
+		logs = atoi(p);
+
+	lws_set_log_level(logs, NULL);
 	lwsl_user("LWS minimal raw vhost | nc localhost 7681\n");
 
+	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
+	info.port = 7681;
+	info.protocols = protocols;
+	info.options = LWS_SERVER_OPTION_ONLY_RAW; /* vhost accepts RAW */
+
 	context = lws_create_context(&info);
 	if (!context) {
 		lwsl_err("lws init failed\n");
diff --git a/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/minimal-ws-client-pmd-bulk.c b/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/minimal-ws-client-pmd-bulk.c
index 2f3c331c94d5714dbac106dad7b033c97c9d3945..fd49dc626b531af6cd42b4f495bf43226c034474 100644
--- a/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/minimal-ws-client-pmd-bulk.c
+++ b/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/minimal-ws-client-pmd-bulk.c
@@ -72,46 +72,40 @@ void sigint_handler(int sig)
 	interrupted = 1;
 }
 
-static int findswitch(int argc, char **argv, const char *val)
-{
-	while (--argc > 0) {
-		if (!strcmp(argv[argc], val))
-			return argc;
-	}
-
-	return 0;
-}
-
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	struct lws_context_creation_info info;
 	struct lws_context *context;
-	int n = 0;
+	const char *p;
+	int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
+			/* for LLL_ verbosity above NOTICE to be built into lws,
+			 * lws must have been configured and built with
+			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
+			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
+			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
+			/* | LLL_DEBUG */;
 
 	signal(SIGINT, sigint_handler);
 
+	if ((p = lws_cmdline_option(argc, argv, "-d")))
+		logs = atoi(p);
+
+	lws_set_log_level(logs, NULL);
+	lwsl_user("LWS minimal ws client + permessage-deflate + multifragment bulk message\n");
+	lwsl_user("   needs minimal-ws-server-pmd-bulk running to communicate with\n");
+	lwsl_user("   %s [-n (no exts)] [-c (compressible)]\n", argv[0]);
+
 	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
 	info.port = CONTEXT_PORT_NO_LISTEN;
 	info.protocols = protocols;
 	info.pvo = &pvo;
-	if (!findswitch(argc, argv, "-n"))
+	if (!lws_cmdline_option(argc, argv, "-n"))
 		info.extensions = extensions;
 	info.pt_serv_buf_size = 32 * 1024;
 
-	if (!findswitch(argc, argv, "-c"))
+	if (!lws_cmdline_option(argc, argv, "-c"))
 		options |= 1;
 
-	lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
-			/* for LLL_ verbosity above NOTICE to be built into lws,
-			 * lws must have been configured and built with
-			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
-			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
-			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
-			/* | LLL_DEBUG */, NULL);
-
-	lwsl_user("LWS minimal ws client + permessage-deflate + multifragment bulk message\n");
-	lwsl_user("   needs minimal-ws-server-pmd-bulk running to communicate with\n");
-	lwsl_user("   %s [-n (no exts)] [-c (compressible)]\n", argv[0]);
 	context = lws_create_context(&info);
 	if (!context) {
 		lwsl_err("lws init failed\n");
diff --git a/minimal-examples/ws-client/minimal-ws-client-tx/minimal-ws-client.c b/minimal-examples/ws-client/minimal-ws-client-tx/minimal-ws-client.c
index 98a16bee02048d35ebea512ab3574c611e146f64..9d2a0138bb62ebfe3a24bf971c599cbe8e2aafd7 100644
--- a/minimal-examples/ws-client/minimal-ws-client-tx/minimal-ws-client.c
+++ b/minimal-examples/ws-client/minimal-ws-client-tx/minimal-ws-client.c
@@ -286,22 +286,25 @@ sigint_handler(int sig)
 	interrupted = 1;
 }
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	struct lws_context_creation_info info;
 	struct lws_context *context;
-	int n = 0;
-
-	signal(SIGINT, sigint_handler);
-
-	lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
+	const char *p;
+	int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
 			/* for LLL_ verbosity above NOTICE to be built into lws,
 			 * lws must have been configured and built with
 			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
 			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
 			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
-			/* | LLL_DEBUG */, NULL);
+			/* | LLL_DEBUG */;
+
+	signal(SIGINT, sigint_handler);
+
+	if ((p = lws_cmdline_option(argc, argv, "-d")))
+		logs = atoi(p);
 
+	lws_set_log_level(logs, NULL);
 	lwsl_user("LWS minimal ws client tx\n");
 	lwsl_user("  Run minimal-ws-broker and browse to that\n");
 
diff --git a/minimal-examples/ws-server/minimal-ws-broker/minimal-ws-broker.c b/minimal-examples/ws-server/minimal-ws-broker/minimal-ws-broker.c
index 18ac0ba6c1aaca3ad506db3cdba95c7946531cc0..5e6de4a1989a54d9b5da30fe0175a76c63e9b7ae 100644
--- a/minimal-examples/ws-server/minimal-ws-broker/minimal-ws-broker.c
+++ b/minimal-examples/ws-server/minimal-ws-broker/minimal-ws-broker.c
@@ -54,29 +54,32 @@ void sigint_handler(int sig)
 	interrupted = 1;
 }
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	struct lws_context_creation_info info;
 	struct lws_context *context;
-	int n = 0;
-
-	signal(SIGINT, sigint_handler);
-
-	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
-	info.port = 7681;
-	info.mounts = &mount;
-	info.protocols = protocols;
-
-	lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
+	const char *p;
+	int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
 			/* for LLL_ verbosity above NOTICE to be built into lws,
 			 * lws must have been configured and built with
 			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
 			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
 			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
-			/* | LLL_DEBUG */, NULL);
+			/* | LLL_DEBUG */;
 
+	signal(SIGINT, sigint_handler);
+
+	if ((p = lws_cmdline_option(argc, argv, "-d")))
+		logs = atoi(p);
+
+	lws_set_log_level(logs, NULL);
 	lwsl_user("LWS minimal ws broker | visit http://localhost:7681\n");
 
+	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
+	info.port = 7681;
+	info.mounts = &mount;
+	info.protocols = protocols;
+
 	context = lws_create_context(&info);
 	if (!context) {
 		lwsl_err("lws init failed\n");
diff --git a/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/minimal-ws-server-pmd-bulk.c b/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/minimal-ws-server-pmd-bulk.c
index 301ab8d1ceb82eabfb65499222406a0153322015..daa6fc7ef77b8c9b716f4aa6029c85e8ed6fe94c 100644
--- a/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/minimal-ws-server-pmd-bulk.c
+++ b/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/minimal-ws-server-pmd-bulk.c
@@ -87,48 +87,42 @@ void sigint_handler(int sig)
 	interrupted = 1;
 }
 
-static int findswitch(int argc, char **argv, const char *val)
-{
-	while (--argc > 0) {
-		if (!strcmp(argv[argc], val))
-			return 1;
-	}
-
-	return 0;
-}
-
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	struct lws_context_creation_info info;
 	struct lws_context *context;
-	int n = 0;
+	const char *p;
+	int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
+			/* for LLL_ verbosity above NOTICE to be built into lws,
+			 * lws must have been configured and built with
+			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
+			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
+			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
+			/* | LLL_DEBUG */;
 
 	signal(SIGINT, sigint_handler);
 
+	if ((p = lws_cmdline_option(argc, argv, "-d")))
+		logs = atoi(p);
+
+	lws_set_log_level(logs, NULL);
+	lwsl_user("LWS minimal ws server + permessage-deflate | visit http://localhost:7681\n");
+	lwsl_user("   %s [-n (no exts)] [-c (compressible)]\n", argv[0]);
+
 	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
 	info.port = 7681;
 	info.mounts = &mount;
 	info.protocols = protocols;
 	info.pvo = &pvo;
 
-	if (!findswitch(argc, argv, "-n"))
+	if (!lws_cmdline_option(argc, argv, "-n"))
 		info.extensions = extensions;
 
-	if (!findswitch(argc, argv, "-c"))
+	if (!lws_cmdline_option(argc, argv, "-c"))
 		options |= 1;
 
 	info.pt_serv_buf_size = 32 * 1024;
 
-	lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
-			/* for LLL_ verbosity above NOTICE to be built into lws,
-			 * lws must have been configured and built with
-			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
-			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
-			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
-			/* | LLL_DEBUG */, NULL);
-
-	lwsl_user("LWS minimal ws server + permessage-deflate | visit http://localhost:7681\n");
-	lwsl_user("   %s [-n (no exts)] [-c (compressible)]\n", argv[0]);
 	context = lws_create_context(&info);
 	if (!context) {
 		lwsl_err("lws init failed\n");
diff --git a/minimal-examples/ws-server/minimal-ws-server-pmd/minimal-ws-server-pmd.c b/minimal-examples/ws-server/minimal-ws-server-pmd/minimal-ws-server-pmd.c
index a36343d1701081fd3f3092489d511093741bf941..25cded376b72f0d972c353fcf563462822ef1244 100644
--- a/minimal-examples/ws-server/minimal-ws-server-pmd/minimal-ws-server-pmd.c
+++ b/minimal-examples/ws-server/minimal-ws-server-pmd/minimal-ws-server-pmd.c
@@ -64,30 +64,33 @@ void sigint_handler(int sig)
 	interrupted = 1;
 }
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	struct lws_context_creation_info info;
 	struct lws_context *context;
-	int n = 0;
+	const char *p;
+	int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
+			/* for LLL_ verbosity above NOTICE to be built into lws,
+			 * lws must have been configured and built with
+			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
+			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
+			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
+			/* | LLL_DEBUG */;
 
 	signal(SIGINT, sigint_handler);
 
+	if ((p = lws_cmdline_option(argc, argv, "-d")))
+		logs = atoi(p);
+
+	lws_set_log_level(logs, NULL);
+	lwsl_user("LWS minimal ws server + permessage-deflate | visit http://localhost:7681\n");
+
 	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
 	info.port = 7681;
 	info.mounts = &mount;
 	info.protocols = protocols;
 	info.extensions = extensions;
 
-	lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
-			/* for LLL_ verbosity above NOTICE to be built into lws,
-			 * lws must have been configured and built with
-			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
-			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
-			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
-			/* | LLL_DEBUG */, NULL);
-
-	lwsl_user("LWS minimal ws server + permessage-deflate | visit http://localhost:7681\n");
-
 	context = lws_create_context(&info);
 	if (!context) {
 		lwsl_err("lws init failed\n");
diff --git a/minimal-examples/ws-server/minimal-ws-server-ring/minimal-ws-server.c b/minimal-examples/ws-server/minimal-ws-server-ring/minimal-ws-server.c
index 2762739b00c3682c26d73de32da699cb048b9713..1da75383be27fb25264c87dc872bc22c7f756f11 100644
--- a/minimal-examples/ws-server/minimal-ws-server-ring/minimal-ws-server.c
+++ b/minimal-examples/ws-server/minimal-ws-server-ring/minimal-ws-server.c
@@ -54,29 +54,32 @@ void sigint_handler(int sig)
 	interrupted = 1;
 }
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	struct lws_context_creation_info info;
 	struct lws_context *context;
-	int n = 0;
-
-	signal(SIGINT, sigint_handler);
-
-	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
-	info.port = 7681;
-	info.mounts = &mount;
-	info.protocols = protocols;
-
-	lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
+	const char *p;
+	int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
 			/* for LLL_ verbosity above NOTICE to be built into lws,
 			 * lws must have been configured and built with
 			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
 			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
 			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
-			/* | LLL_DEBUG */, NULL);
+			/* | LLL_DEBUG */;
 
+	signal(SIGINT, sigint_handler);
+
+	if ((p = lws_cmdline_option(argc, argv, "-d")))
+		logs = atoi(p);
+
+	lws_set_log_level(logs, NULL);
 	lwsl_user("LWS minimal ws server (lws_ring) | visit http://localhost:7681\n");
 
+	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
+	info.port = 7681;
+	info.mounts = &mount;
+	info.protocols = protocols;
+
 	context = lws_create_context(&info);
 	if (!context) {
 		lwsl_err("lws init failed\n");
diff --git a/minimal-examples/ws-server/minimal-ws-server-threads/minimal-ws-server.c b/minimal-examples/ws-server/minimal-ws-server-threads/minimal-ws-server.c
index 0da7e38624ab647497cfa512a89610331d8e48df..1632626a424db47112ded4cb7f693ccd831c5583 100644
--- a/minimal-examples/ws-server/minimal-ws-server-threads/minimal-ws-server.c
+++ b/minimal-examples/ws-server/minimal-ws-server-threads/minimal-ws-server.c
@@ -82,29 +82,33 @@ void sigint_handler(int sig)
 	interrupted = 1;
 }
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	struct lws_context_creation_info info;
 	struct lws_context *context;
+	const char *p;
+	int logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
+			/* for LLL_ verbosity above NOTICE to be built into lws,
+			 * lws must have been configured and built with
+			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
+			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
+			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
+			/* | LLL_DEBUG */;
 
 	signal(SIGINT, sigint_handler);
 
+	if ((p = lws_cmdline_option(argc, argv, "-d")))
+		logs = atoi(p);
+
+	lws_set_log_level(logs, NULL);
+	lwsl_user("LWS minimal ws server + threads | visit http://localhost:7681\n");
+
 	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
 	info.port = 7681;
 	info.mounts = &mount;
 	info.protocols = protocols;
 	info.pvo = &pvo; /* per-vhost options */
 
-	lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
-			/* for LLL_ verbosity above NOTICE to be built into lws,
-			 * lws must have been configured and built with
-			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
-			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
-			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
-			/* | LLL_DEBUG */, NULL);
-
-	lwsl_user("LWS minimal ws server + threads | visit http://localhost:7681\n");
-
 	context = lws_create_context(&info);
 	if (!context) {
 		lwsl_err("lws init failed\n");
diff --git a/minimal-examples/ws-server/minimal-ws-server/minimal-ws-server.c b/minimal-examples/ws-server/minimal-ws-server/minimal-ws-server.c
index d22a7d7c87df66a0be3e6e52f3ddedac1013329c..8b67503d10feacf9b2c11e5923acdf3d0f8adc12 100644
--- a/minimal-examples/ws-server/minimal-ws-server/minimal-ws-server.c
+++ b/minimal-examples/ws-server/minimal-ws-server/minimal-ws-server.c
@@ -54,29 +54,32 @@ void sigint_handler(int sig)
 	interrupted = 1;
 }
 
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
 {
 	struct lws_context_creation_info info;
 	struct lws_context *context;
-	int n = 0;
-
-	signal(SIGINT, sigint_handler);
-
-	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
-	info.port = 7681;
-	info.mounts = &mount;
-	info.protocols = protocols;
-
-	lws_set_log_level(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
+	const char *p;
+	int n = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE
 			/* for LLL_ verbosity above NOTICE to be built into lws,
 			 * lws must have been configured and built with
 			 * -DCMAKE_BUILD_TYPE=DEBUG instead of =RELEASE */
 			/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */
 			/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */
-			/* | LLL_DEBUG */, NULL);
+			/* | LLL_DEBUG */;
 
+	signal(SIGINT, sigint_handler);
+
+	if ((p = lws_cmdline_option(argc, argv, "-d")))
+		logs = atoi(p);
+
+	lws_set_log_level(logs, NULL);
 	lwsl_user("LWS minimal ws server | visit http://localhost:7681\n");
 
+	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
+	info.port = 7681;
+	info.mounts = &mount;
+	info.protocols = protocols;
+
 	context = lws_create_context(&info);
 	if (!context) {
 		lwsl_err("lws init failed\n");