\subsubsection*{Context and Vhost releated functions}
L\+WS requires that there is one context, in which you may define multiple vhosts. Each vhost is a virtual host, with either its own listen port or sharing an existing one. Each vhost has its own S\+SL context that can be set up individually or left disabled.
If you don\textquotesingle{}t care about multiple \char`\"{}site\char`\"{} support, you can ignore it and lws will create a single default vhost at context creation time.
\subsubsection[{\texorpdfstring{lws\+\_\+context\+\_\+options}{lws\_context\_options}}]{\setlength{\rightskip}{0pt plus 5cm}enum {\bf lws\+\_\+context\+\_\+options}}\hypertarget{group__context-and-vhost_ga41c2d763f78cc248df3b9f8645dbd2a5}{}\label{group__context-and-vhost_ga41c2d763f78cc248df3b9f8645dbd2a5}
}](VH) Don\textquotesingle{}t allow the connection unless the client has a client cert that we recognize; provides L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+D\+O\+\_\+\+S\+S\+L\+\_\+\+G\+L\+O\+B\+A\+L\+\_\+\+I\+N\+IT \index{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+S\+K\+I\+P\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+C\+A\+N\+O\+N\+I\+C\+A\+L\+\_\+\+N\+A\+ME@{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+S\+K\+I\+P\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+C\+A\+N\+O\+N\+I\+C\+A\+L\+\_\+\+N\+A\+ME}!Context-\/and-\/vhost@{Context-\/and-\/vhost}}\index{Context-\/and-\/vhost@{Context-\/and-\/vhost}!L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+S\+K\+I\+P\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+C\+A\+N\+O\+N\+I\+C\+A\+L\+\_\+\+N\+A\+ME@{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+S\+K\+I\+P\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+C\+A\+N\+O\+N\+I\+C\+A\+L\+\_\+\+N\+A\+ME}}\item[{\em
}](C\+TX) Don\textquotesingle{}t try to get the server\textquotesingle{}s hostname \index{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+A\+L\+L\+O\+W\+\_\+\+N\+O\+N\+\_\+\+S\+S\+L\+\_\+\+O\+N\+\_\+\+S\+S\+L\+\_\+\+P\+O\+RT@{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+A\+L\+L\+O\+W\+\_\+\+N\+O\+N\+\_\+\+S\+S\+L\+\_\+\+O\+N\+\_\+\+S\+S\+L\+\_\+\+P\+O\+RT}!Context-\/and-\/vhost@{Context-\/and-\/vhost}}\index{Context-\/and-\/vhost@{Context-\/and-\/vhost}!L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+A\+L\+L\+O\+W\+\_\+\+N\+O\+N\+\_\+\+S\+S\+L\+\_\+\+O\+N\+\_\+\+S\+S\+L\+\_\+\+P\+O\+RT@{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+A\+L\+L\+O\+W\+\_\+\+N\+O\+N\+\_\+\+S\+S\+L\+\_\+\+O\+N\+\_\+\+S\+S\+L\+\_\+\+P\+O\+RT}}\item[{\em
}](VH) Allow non-\/\+S\+SL (plaintext) connections on the same port as S\+SL is listening... undermines the security of S\+SL; provides L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+D\+O\+\_\+\+S\+S\+L\+\_\+\+G\+L\+O\+B\+A\+L\+\_\+\+I\+N\+IT \index{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+L\+I\+B\+EV@{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+L\+I\+B\+EV}!Context-\/and-\/vhost@{Context-\/and-\/vhost}}\index{Context-\/and-\/vhost@{Context-\/and-\/vhost}!L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+L\+I\+B\+EV@{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+L\+I\+B\+EV}}\item[{\em
}](VH) Disable I\+P\+V6 support \index{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+D\+I\+S\+A\+B\+L\+E\+\_\+\+O\+S\+\_\+\+C\+A\+\_\+\+C\+E\+R\+TS@{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+D\+I\+S\+A\+B\+L\+E\+\_\+\+O\+S\+\_\+\+C\+A\+\_\+\+C\+E\+R\+TS}!Context-\/and-\/vhost@{Context-\/and-\/vhost}}\index{Context-\/and-\/vhost@{Context-\/and-\/vhost}!L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+D\+I\+S\+A\+B\+L\+E\+\_\+\+O\+S\+\_\+\+C\+A\+\_\+\+C\+E\+R\+TS@{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+D\+I\+S\+A\+B\+L\+E\+\_\+\+O\+S\+\_\+\+C\+A\+\_\+\+C\+E\+R\+TS}}\item[{\em
}](VH) Don\textquotesingle{}t load OS CA certs, you will need to load your own CA cert(s) \index{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+P\+E\+E\+R\+\_\+\+C\+E\+R\+T\+\_\+\+N\+O\+T\+\_\+\+R\+E\+Q\+U\+I\+R\+ED@{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+P\+E\+E\+R\+\_\+\+C\+E\+R\+T\+\_\+\+N\+O\+T\+\_\+\+R\+E\+Q\+U\+I\+R\+ED}!Context-\/and-\/vhost@{Context-\/and-\/vhost}}\index{Context-\/and-\/vhost@{Context-\/and-\/vhost}!L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+P\+E\+E\+R\+\_\+\+C\+E\+R\+T\+\_\+\+N\+O\+T\+\_\+\+R\+E\+Q\+U\+I\+R\+ED@{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+P\+E\+E\+R\+\_\+\+C\+E\+R\+T\+\_\+\+N\+O\+T\+\_\+\+R\+E\+Q\+U\+I\+R\+ED}}\item[{\em
}](VH) Accept connections with no valid Cert (eg, selfsigned) \index{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+V\+A\+L\+I\+D\+A\+T\+E\+\_\+\+U\+T\+F8@{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+V\+A\+L\+I\+D\+A\+T\+E\+\_\+\+U\+T\+F8}!Context-\/and-\/vhost@{Context-\/and-\/vhost}}\index{Context-\/and-\/vhost@{Context-\/and-\/vhost}!L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+V\+A\+L\+I\+D\+A\+T\+E\+\_\+\+U\+T\+F8@{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+V\+A\+L\+I\+D\+A\+T\+E\+\_\+\+U\+T\+F8}}\item[{\em
}](VH) Use http redirect to force http to https (deprecated\+: use mount redirection) \index{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+D\+O\+\_\+\+S\+S\+L\+\_\+\+G\+L\+O\+B\+A\+L\+\_\+\+I\+N\+IT@{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+D\+O\+\_\+\+S\+S\+L\+\_\+\+G\+L\+O\+B\+A\+L\+\_\+\+I\+N\+IT}!Context-\/and-\/vhost@{Context-\/and-\/vhost}}\index{Context-\/and-\/vhost@{Context-\/and-\/vhost}!L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+D\+O\+\_\+\+S\+S\+L\+\_\+\+G\+L\+O\+B\+A\+L\+\_\+\+I\+N\+IT@{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+D\+O\+\_\+\+S\+S\+L\+\_\+\+G\+L\+O\+B\+A\+L\+\_\+\+I\+N\+IT}}\item[{\em
}](C\+TX) Initialize the S\+SL library at all \index{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+E\+X\+P\+L\+I\+C\+I\+T\+\_\+\+V\+H\+O\+S\+TS@{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+E\+X\+P\+L\+I\+C\+I\+T\+\_\+\+V\+H\+O\+S\+TS}!Context-\/and-\/vhost@{Context-\/and-\/vhost}}\index{Context-\/and-\/vhost@{Context-\/and-\/vhost}!L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+E\+X\+P\+L\+I\+C\+I\+T\+\_\+\+V\+H\+O\+S\+TS@{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+E\+X\+P\+L\+I\+C\+I\+T\+\_\+\+V\+H\+O\+S\+TS}}\item[{\em
}](C\+TX) Only create the context when calling context create api, implies user code will create its own vhosts \index{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+U\+N\+I\+X\+\_\+\+S\+O\+CK@{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+U\+N\+I\+X\+\_\+\+S\+O\+CK}!Context-\/and-\/vhost@{Context-\/and-\/vhost}}\index{Context-\/and-\/vhost@{Context-\/and-\/vhost}!L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+U\+N\+I\+X\+\_\+\+S\+O\+CK@{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+U\+N\+I\+X\+\_\+\+S\+O\+CK}}\item[{\em
}](VH) Use Unix socket \index{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+S\+TS@{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+S\+TS}!Context-\/and-\/vhost@{Context-\/and-\/vhost}}\index{Context-\/and-\/vhost@{Context-\/and-\/vhost}!L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+S\+TS@{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+S\+TS}}\item[{\em
}](VH) Send Strict Transport Security header, making clients subsequently go to https even if user asked for http \index{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+I\+P\+V6\+\_\+\+V6\+O\+N\+L\+Y\+\_\+\+M\+O\+D\+I\+FY@{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+I\+P\+V6\+\_\+\+V6\+O\+N\+L\+Y\+\_\+\+M\+O\+D\+I\+FY}!Context-\/and-\/vhost@{Context-\/and-\/vhost}}\index{Context-\/and-\/vhost@{Context-\/and-\/vhost}!L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+I\+P\+V6\+\_\+\+V6\+O\+N\+L\+Y\+\_\+\+M\+O\+D\+I\+FY@{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+I\+P\+V6\+\_\+\+V6\+O\+N\+L\+Y\+\_\+\+M\+O\+D\+I\+FY}}\item[{\em
}](VH) Enable L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+I\+P\+V6\+\_\+\+V6\+O\+N\+L\+Y\+\_\+\+V\+A\+L\+UE to take effect \index{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+I\+P\+V6\+\_\+\+V6\+O\+N\+L\+Y\+\_\+\+V\+A\+L\+UE@{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+I\+P\+V6\+\_\+\+V6\+O\+N\+L\+Y\+\_\+\+V\+A\+L\+UE}!Context-\/and-\/vhost@{Context-\/and-\/vhost}}\index{Context-\/and-\/vhost@{Context-\/and-\/vhost}!L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+I\+P\+V6\+\_\+\+V6\+O\+N\+L\+Y\+\_\+\+V\+A\+L\+UE@{L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+I\+P\+V6\+\_\+\+V6\+O\+N\+L\+Y\+\_\+\+V\+A\+L\+UE}}\item[{\em
\hyperlink{group__context-and-vhost_gaeb12f934bfd178bd2132a9e73fc641da}{lws\+\_\+context\+\_\+user()} -\/ get the user data associated with the context
\begin{DoxyParams}{Parameters}
{\em context}& Websocket context\\
\hline
\end{DoxyParams}
This returns the optional user allocation that can be attached to the context the sockets live in at context\+\_\+create time. It\textquotesingle{}s a way to let all sockets serviced in the same context share data without using globals statics in the user code. \index{Context-\/and-\/vhost@{Context-\/and-\/vhost}!lws\+\_\+create\+\_\+context@{lws\+\_\+create\+\_\+context}}
\hyperlink{group__context-and-vhost_ga0c54c667ccd9b8b3dddcd123ca72f87c}{lws\+\_\+create\+\_\+vhost()} -\/ Create a vhost (virtual server context)
\begin{DoxyParams}{Parameters}
{\em context}& pointer to result of \hyperlink{group__context-and-vhost_gaf2fff58562caab7510c41eeac85a8648}{lws\+\_\+create\+\_\+context()}\\
\hline
{\em info}& pointer to struct with parameters\\
\hline
\end{DoxyParams}
This function creates a virtual server (vhost) using the vhost-\/related members of the info struct. You can create many vhosts inside one context if you created the context with the option L\+W\+S\+\_\+\+S\+E\+R\+V\+E\+R\+\_\+\+O\+P\+T\+I\+O\+N\+\_\+\+E\+X\+P\+L\+I\+C\+I\+T\+\_\+\+V\+H\+O\+S\+TS \index{Context-\/and-\/vhost@{Context-\/and-\/vhost}!lws\+\_\+get\+\_\+vhost@{lws\+\_\+get\+\_\+vhost}}
\hyperlink{group__context-and-vhost_gae2134657cdd2ea7a59e13ad314e4c50d}{lws\+\_\+json\+\_\+dump\+\_\+context()} -\/ describe context state and stats in J\+S\+ON
\hyperlink{group__context-and-vhost_ga94e6cc2223c4eec316b13bcebc3628b6}{lws\+\_\+json\+\_\+dump\+\_\+vhost()} -\/ describe vhost state and stats in J\+S\+ON
\hyperlink{group__context-and-vhost_ga7e9d5405547a457d86e0b4f0ae2bb1c4}{lws\+\_\+set\+\_\+proxy()} -\/ Setups proxy to lws\+\_\+context.
\begin{DoxyParams}{Parameters}
{\em vhost}& pointer to struct lws\+\_\+vhost you want set proxy for \\
\hline
{\em proxy}& pointer to c string containing proxy in format address\+:port\\
\hline
\end{DoxyParams}
Returns 0 if proxy string was parsed and proxy was setup. Returns -\/1 if proxy is N\+U\+LL or has incorrect format.
This is only required if your OS does not provide the http\+\_\+proxy environment variable (eg, O\+SX)
I\+M\+P\+O\+R\+T\+A\+N\+T! You should call this function right after creation of the lws\+\_\+context and before call to connect. If you call this function after connect behavior is undefined. This function will override proxy settings made on lws\+\_\+context creation with genenv() call. \index{Context-\/and-\/vhost@{Context-\/and-\/vhost}!lws\+\_\+vhost\+\_\+get@{lws\+\_\+vhost\+\_\+get}}
\item[\hyperlink{deprecated__deprecated000001}{Deprecated}]deprecated\+: use \hyperlink{group__context-and-vhost_ga06e77ce2916f8bc9826ef8d9d68e3932}{lws\+\_\+get\+\_\+vhost()}\end{DoxyRefDesc}
\hyperlink{group__context-and-vhost_ga98d88c9080fd89c37114363a6474ea73}{lwsws\+\_\+get\+\_\+config\+\_\+globals()} -\/ Parse a J\+S\+ON server config file
\begin{DoxyParams}{Parameters}
{\em info}& pointer to struct with parameters \\
\hline
{\em d}& filepath of the config file \\
\hline
{\em config\+\_\+strings}& storage for the config strings extracted from J\+S\+ON, the pointer is incremented as strings are stored \\
\hline
{\em len}& pointer to the remaining length left in config\+\_\+strings the value is decremented as strings are stored\\
\hline
\end{DoxyParams}
This function prepares a n \hyperlink{structlws__context__creation__info}{lws\+\_\+context\+\_\+creation\+\_\+info} struct with global settings from a file d.
Requires C\+Make option L\+W\+S\+\_\+\+W\+I\+T\+H\+\_\+\+L\+E\+J\+P\+\_\+\+C\+O\+NF to have been enabled \index{Context-\/and-\/vhost@{Context-\/and-\/vhost}!lwsws\+\_\+get\+\_\+config\+\_\+vhosts@{lwsws\+\_\+get\+\_\+config\+\_\+vhosts}}
\hyperlink{group__context-and-vhost_ga341064721add2618ae1b29717493a212}{lwsws\+\_\+get\+\_\+config\+\_\+vhosts()} -\/ Create vhosts from a J\+S\+ON server config file
\begin{DoxyParams}{Parameters}
{\em context}& pointer to result of \hyperlink{group__context-and-vhost_gaf2fff58562caab7510c41eeac85a8648}{lws\+\_\+create\+\_\+context()}\\
\hline
{\em info}& pointer to struct with parameters \\
\hline
{\em d}& filepath of the config file \\
\hline
{\em config\+\_\+strings}& storage for the config strings extracted from J\+S\+ON, the pointer is incremented as strings are stored \\
\hline
{\em len}& pointer to the remaining length left in config\+\_\+strings the value is decremented as strings are stored\\
\hline
\end{DoxyParams}
This function creates vhosts into a context according to the settings in J\+S\+ON files found in directory d.
Requires C\+Make option L\+W\+S\+\_\+\+W\+I\+T\+H\+\_\+\+L\+E\+J\+P\+\_\+\+C\+O\+NF to have been enabled