aboutsummaryrefslogtreecommitdiff
path: root/doc/installation.html
diff options
context:
space:
mode:
Diffstat (limited to 'doc/installation.html')
-rw-r--r--doc/installation.html149
1 files changed, 149 insertions, 0 deletions
diff --git a/doc/installation.html b/doc/installation.html
new file mode 100644
index 0000000..d5e82d9
--- /dev/null
+++ b/doc/installation.html
@@ -0,0 +1,149 @@
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3<html>
4
5<head>
6<meta name="description" content="LuaSocket: Introduction to the core">
7<meta name="keywords" content="Lua, LuaSocket, TCP, UDP, Network, Support,
8Installation">
9<title>LuaSocket: Instalation</title>
10<link rel="stylesheet" href="reference.css" type="text/css">
11</head>
12
13<body>
14
15<!-- header +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
16
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="home.html">home</a> &middot;
29<a href="home.html#download">download</a> &middot;
30<a href="instalation.html">instalation</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>
37
38<!-- instalation ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
39
40<h2>Instalation</h2>
41
42<p> LuaSocket 2.0 uses the new package proposal for Lua 5.1, throught the
43compatibility module <a href=http://www.keplerproject.org/compat/>
44Compat-5.1</a> released in conjunction with Roberto Ierusalimschy and <a
45href=http://www.keplerproject.org/">The Kepler project</a>. The proposal
46was considered important enough by the community to justify early adoption.
47All Lua library developers are encouraged to change their libraries in
48preparation for the release of Lua 5.1. </p>
49
50<p> As far as LuaSocket is concerned, this means that whoever is
51deploying a solution that uses LuaSocket has a lot of freedom. Here we
52describe only the standard distribution. If the standard doesn't meet your
53needs, we refer you to the Lua discussion list, where any quesetion about
54the package scheme will likely be answered promptly.
55</p>
56
57<h3>Directory structure</h3>
58
59<p> The new package scheme has a root directory for the libraries installed
60on a given system. Let's call this directory <tt>&lt;ROOT&gt;</tt>.
61On my system, this is the <tt>/usr/local/share/lua/5.0</tt> directory.
62Here is the standard LuaSocket distribution directory structure:</p>
63
64<pre class=example>
65&lt;ROOT&gt;/compat-5.1.lua
66&lt;ROOT&gt;/socket.lua
67&lt;ROOT&gt;/lsocket.dll
68&lt;ROOT&gt;/mime.lua
69&lt;ROOT&gt;/lmime.dll
70&lt;ROOT&gt;/ltn12.lua
71&lt;ROOT&gt;/socket/http.lua
72&lt;ROOT&gt;/socket/tp.lua
73&lt;ROOT&gt;/socket/ftp.lua
74&lt;ROOT&gt;/socket/smtp.lua
75&lt;ROOT&gt;/socket/url.lua
76</pre>
77
78<p> Naturally, on Unix systems, <tt>lsocket.dll</tt> and <tt>lmime.dll</tt>
79would be replaced by <tt>lsocket.so</tt> and <tt>lmime.so</tt>. In Mac OS
80X, they would be replaced by <tt>lsocket.dylib</tt> and
81<tt>lmime.dylib</tt>. </p>
82
83<p> In order for the interpreter to find all LuaSocket components, three
84environment variables need to be set. The first environment variable tells
85the interpreter to load the <tt>compat-5.1.lua</tt> module. </p>
86
87<pre class=example>
88LUA_INIT=@&lt;ROOT&gt;/compat-5.1.lua
89</pre>
90
91The other two environment variables instruct the compatibility module to
92look for dynamic libraries and modules in the appropriate directories and
93with the appropriate filename extensions.
94
95<pre class=example>
96LUA_PATH=&lt;ROOT&gt;/?.lua;?.lua
97LUA_CPATH=&lt;ROOT&gt;/?.dll;?.dll
98</pre>
99
100<p> Again, naturally, in Unix the shared library extension would be
101<tt>.so</tt> instead of <tt>.dll</tt> and on Mac OS X they would be
102<tt>.dylib</tt></p>
103
104<h3>Using LuaSocket</h3>
105
106<p> With the above setup, and an interpreter with shared library support,
107it should be easy to use LuaSocket. Just fire the interpreter and use the
108<tt>require</tt> function to gain access to whatever module you need:</p>
109
110<pre class=example>
111Lua 5.0.2 Copyright (C) 1994-2004 Tecgraf, PUC-Rio
112&gt; socket = require("socket")
113&gt; print(socket.VERSION)
114--&gt; LuaSocket 2.0 (beta3)
115</pre>
116
117<p> Each module loads their dependencies automatically, so you only need to
118load the modues you are directly dependent upon. <p>
119
120<pre class=example>
121Lua 5.0.2 Copyright (C) 1994-2004 Tecgraf, PUC-Rio
122&gt; http = require("socket.http")
123&gt; print(http.get("http://www.tecgraf.puc-rio.br/luasocket"))
124--&gt; homepage gets dumped to terminal
125</pre>
126
127<!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
128
129<div class=footer>
130<hr>
131<center>
132<p class=bar>
133<a href="home.html">home</a> &middot;
134<a href="home.html#down">download</a> &middot;
135<a href="instalation.html">instalation</a> &middot;
136<a href="introduction.html">introduction</a> &middot;
137<a href="reference.html">reference</a>
138</p>
139<p>
140<small>
141Last modified by Diego Nehab on <br>
142Thu Jun 17 02:47:21 EDT 2004
143</small>
144</p>
145</center>
146</div>
147
148</body>
149</html>