break client connect into states and apply timeout

Doing a client connect was atomic until now, blocking
all the other service while it waited for proxy and / or
server response.

This patch uses the new timeout system and breaks the
client connect sequence into three states handled by
the normal poll() processing.  It means that there are
now no blocking network delays and it's all handled
by the main state machine.

Signed-off-by: Andy Green <andy@warmcat.com>
diff --git a/libwebsockets-api-doc.html b/libwebsockets-api-doc.html
index feb6638..e351ab8 100644
--- a/libwebsockets-api-doc.html
+++ b/libwebsockets-api-doc.html
@@ -141,6 +141,27 @@
 <dd>Protocol whose connections will get callbacks
 </dl>
 <hr>
+<h2>libwebsocket_set_timeout - marks the wsi as subject to a timeout</h2>
+<i>void</i>
+<b>libwebsocket_set_timeout</b>
+(<i>struct libwebsocket *</i> <b>wsi</b>,
+<i>enum pending_timeout</i> <b>reason</b>,
+<i>int</i> <b>secs</b>)
+<h3>Arguments</h3>
+<dl>
+<dt><b>wsi</b>
+<dd>Websocket connection instance
+<dt><b>reason</b>
+<dd>timeout reason
+<dt><b>secs</b>
+<dd>how many seconds
+</dl>
+<h3>Description</h3>
+<blockquote>
+<p>
+You will not need this unless you are doing something special
+</blockquote>
+<hr>
 <h2>libwebsocket_get_socket_fd - returns the socket file descriptor</h2>
 <i>int</i>
 <b>libwebsocket_get_socket_fd</b>