beta-0.89.2
[luatex.git] / source / texk / web2c / luatexdir / luasocket / doc / installation.html
blob37c309b5d2417b5c8df1e90a9a88151b1e582f23
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3 <html>
5 <head>
6 <meta name="description" content="LuaSocket: Introduction to the core">
7 <meta name="keywords" content="Lua, LuaSocket, TCP, UDP, Network, Support,
8 Installation">
9 <title>LuaSocket: Installation</title>
10 <link rel="stylesheet" href="reference.css" type="text/css">
11 </head>
13 <body>
15 <!-- header +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
17 <div class=header>
18 <hr>
19 <center>
20 <table summary="LuaSocket logo">
21 <tr><td align=center><a href="http://www.lua.org">
22 <img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
23 </a></td></tr>
24 <tr><td align=center valign=top>Network support for the Lua language
25 </td></tr>
26 </table>
27 <p class=bar>
28 <a href="index.html">home</a> &middot;
29 <a href="index.html#download">download</a> &middot;
30 <a href="installation.html">installation</a> &middot;
31 <a href="introduction.html">introduction</a> &middot;
32 <a href="reference.html">reference</a>
33 </p>
34 </center>
35 <hr>
36 </div>
38 <!-- installation ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
40 <h2>Installation</h2>
42 <p> LuaSocket 2.1-rc still uses Lua&nbsp;5.1's package
43 system. Users that have already made the switch to
44 Lua&nbsp;5.2 should leave the default
45 <tt>LUA_COMPAT_MODULE</tt> defined when compiling their Lua
46 distribution for compatibility with LuaSocket. </p>
48 <p> Here we describe the standard distribution. If the
49 standard doesn't meet your needs, we refer you to the Lua
50 discussion list, where any question about the package scheme
51 will likely already have been answered. </p>
53 <h3>Directory structure</h3>
55 <p> On Unix systems, the standard distribution uses two base
56 directories, one for system dependent files, and another for system
57 independent files. Let's call these directories <tt>&lt;CDIR&gt;</tt>
58 and <tt>&lt;LDIR&gt;</tt>, respectively.
59 For example, in my laptp, Lua&nbsp;5.1 is configured to
60 use '<tt>/usr/local/lib/lua/5.1</tt>' for
61 <tt>&lt;CDIR&gt;</tt> and '<tt>/usr/local/share/lua/5.1</tt>' for
62 <tt>&lt;LDIR&gt;</tt>. On Windows, <tt>&lt;CDIR&gt;</tt>
63 usually points to the directory where the Lua executable is
64 found, and <tt>&lt;LDIR&gt;</tt> points to a
65 <tt>lua/</tt> directory inside <tt>&lt;CDIR&gt;</tt>. (These
66 settings can be overridden by environment variables
67 <tt>LUA_PATH</tt> and <tt>LUA_CPATH</tt>. See the Lua
68 documentation for details.) Here is the standard LuaSocket
69 distribution directory structure:</p>
71 <pre class=example>
72 &lt;LDIR&gt;/ltn12.lua
73 &lt;LDIR&gt;/socket.lua
74 &lt;CDIR&gt;/socket/core.dll
75 &lt;LDIR&gt;/socket/http.lua
76 &lt;LDIR&gt;/socket/tp.lua
77 &lt;LDIR&gt;/socket/ftp.lua
78 &lt;LDIR&gt;/socket/smtp.lua
79 &lt;LDIR&gt;/socket/url.lua
80 &lt;LDIR&gt;/mime.lua
81 &lt;CDIR&gt;/mime/core.dll
82 </pre>
84 <p> Naturally, on Unix systems, <tt>core.dll</tt>
85 would be replaced by <tt>core.so</tt>.
86 </p>
88 <h3>Using LuaSocket</h3>
90 <p> With the above setup, and an interpreter with shared library support,
91 it should be easy to use LuaSocket. Just fire the interpreter and use the
92 <tt>require</tt> function to gain access to whatever module you need:</p>
94 <pre class=example>
95 Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio
96 &gt; socket = require("socket")
97 &gt; print(socket._VERSION)
98 --&gt; LuaSocket 2.1-rc1
99 </pre>
101 <p> Each module loads their dependencies automatically, so you only need to
102 load the modules you directly depend upon: </p>
104 <pre class=example>
105 Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio
106 &gt; http = require("socket.http")
107 &gt; print(http.request("http://www.impa.br/~diego/software/luasocket"))
108 --&gt; homepage gets dumped to terminal
109 </pre>
111 <!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
113 <div class=footer>
114 <hr>
115 <center>
116 <p class=bar>
117 <a href="index.html">home</a> &middot;
118 <a href="index.html#down">download</a> &middot;
119 <a href="installation.html">installation</a> &middot;
120 <a href="introduction.html">introduction</a> &middot;
121 <a href="reference.html">reference</a>
122 </p>
124 <small>
125 Last modified by Diego Nehab on <br>
126 Mon Apr 16 21:01:42 HKT 2012
127 </small>
128 </p>
129 </center>
130 </div>
132 </body>
133 </html>