README.coding add note about closing connections 06/3106/1
authorAndy Green <andy.green@linaro.org>
Fri, 15 Feb 2013 02:25:58 +0000 (10:25 +0800)
committerKevron Rees <kevron_m_rees@linux.intel.com>
Thu, 7 Mar 2013 21:01:36 +0000 (13:01 -0800)
Signed-off-by: Andy Green <andy.green@linaro.org>
README.coding

index 4f4c27a..bb093fb 100644 (file)
@@ -67,6 +67,27 @@ in the ...WRITEABLE callback.
 See the test server code for an example of how to do this.
 
 
+Closing connections from the user side
+--------------------------------------
+
+When you want to close a connection, you do it by returning -1 from a
+callback for that connection.
+
+You can provoke a callback by calling libwebsocket_callback_on_writable on
+the wsi, then notice in the callback you want to close it and just return -1.
+But usually, the decision to close is made in a callback already and returning
+-1 is simple.
+
+If the socket knows the connection is dead, because the peer closed or there
+was an affirmitive network error like a FIN coming, then libwebsockets  will
+take care of closing the connection automatically.
+
+If you have a silently dead connection, it's possible to enter a state where
+the send pipe on the connection is choked but no ack will ever come, so the
+dead connection will never become writeable.  To cover that, you can use TCP
+keepalives (see later in this document)
+
+
 Fragmented messages
 -------------------