From 30f71a8bc42a3d6b23701c216667c7e7c43670cd Mon Sep 17 00:00:00 2001
From: Sergey Lyubka <valenok@gmail.com>
Date: Tue, 16 Jul 2013 07:24:39 +0100
Subject: [PATCH] Added description for the connect() socket interface

---
 UserManual.md | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/UserManual.md b/UserManual.md
index a16d71658..8590dcea3 100644
--- a/UserManual.md
+++ b/UserManual.md
@@ -340,6 +340,23 @@ Mongoose exports the following to the Lua server page:
     mg.version        -- a string that holds Mongoose version
     mg.request_info   -- a table with request information
 
+    -- Connect to the remote TCP server. This function is an implementation
+    -- of simple socket interface. It returns a socket object with three
+    -- methods: send, recv, close, which are synchronous (blocking).
+    -- connect() throws an exception on connection error.
+    connect(host, port, use_ssl)
+
+    -- Example of using connect() interface:
+    local host = 'code.google.com'  -- IP address or domain name
+    local ok, sock = pcall(connect, host, 80, 1)
+    if ok then
+      sock:send('GET /p/mongoose/ HTTP/1.0\r\n' ..
+                'Host: ' .. host .. '\r\n\r\n')
+      local reply = sock:recv()
+      sock:close()
+      -- reply now contains the web page https://code.google.com/p/mongoose
+    end
+
 
 **IMPORTANT: Mongoose does not send HTTP headers for Lua pages. Therefore,
 every Lua Page must begin with HTTP reply line and headers**, like this:
-- 
GitLab