Mercurial > luasocket
comparison doc/installation.html @ 0:4b915342e2a8
LuaSocket 2.0.2 + CMake build description.
author | Eric Wing <ewing . public |-at-| gmail . com> |
---|---|
date | Tue, 26 Aug 2008 18:40:01 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4b915342e2a8 |
---|---|
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, | |
8 Installation"> | |
9 <title>LuaSocket: Installation</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> · | |
29 <a href="home.html#download">download</a> · | |
30 <a href="installation.html">installation</a> · | |
31 <a href="introduction.html">introduction</a> · | |
32 <a href="reference.html">reference</a> | |
33 </p> | |
34 </center> | |
35 <hr> | |
36 </div> | |
37 | |
38 <!-- installation ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | |
39 | |
40 <h2>Installation</h2> | |
41 | |
42 <p> LuaSocket 2.0.2 uses the new package system for Lua 5.1. | |
43 All Lua library developers are encouraged to update their libraries so that | |
44 all libraries can coexist peacefully and users can benefit from the | |
45 standardization and flexibility of the standard. | |
46 </p> | |
47 | |
48 <p> | |
49 Those stuck with Lua 5.0 will need the | |
50 <a href=http://www.keplerproject.org/compat/>compat-5.1</a> | |
51 module. It is maintained by | |
52 <a href=http://www.keplerproject.org/>The Kepler | |
53 Project</a>'s team, and implements the Lua 5.1 package proposal | |
54 on top of Lua 5.0. </p> | |
55 | |
56 <p> Here we will only describe the standard distribution. | |
57 If the standard doesn't meet your needs, we refer you to the | |
58 Lua discussion list, where any question about the package | |
59 scheme will likely already have been answered. </p> | |
60 | |
61 <h3>Directory structure</h3> | |
62 | |
63 <p> On Unix systems, the standard distribution uses two base | |
64 directories, one for system dependent files, and another for system | |
65 independent files. Let's call these directories <tt><CDIR></tt> | |
66 and <tt><LDIR></tt>, respectively. | |
67 For instance, in my laptop, I use '<tt>/usr/local/lib/lua/5.0</tt>' for | |
68 <tt><CDIR></tt> and '<tt>/usr/local/share/lua/5.0</tt>' for | |
69 <tt><LDIR></tt>. On Windows, sometimes only one directory is used, say | |
70 '<tt>c:\program files\lua\5.0</tt>'. Here is the standard LuaSocket | |
71 distribution directory structure:</p> | |
72 | |
73 <pre class=example> | |
74 <LDIR>/compat-5.1.lua | |
75 <LDIR>/ltn12.lua | |
76 <LDIR>/socket.lua | |
77 <CDIR>/socket/core.dll | |
78 <LDIR>/socket/http.lua | |
79 <LDIR>/socket/tp.lua | |
80 <LDIR>/socket/ftp.lua | |
81 <LDIR>/socket/smtp.lua | |
82 <LDIR>/socket/url.lua | |
83 <LDIR>/mime.lua | |
84 <CDIR>/mime/core.dll | |
85 </pre> | |
86 | |
87 <p> Naturally, on Unix systems, <tt>core.dll</tt> | |
88 would be replaced by <tt>core.so</tt>. | |
89 </p> | |
90 | |
91 <p> In order for the interpreter to find all LuaSocket components, three | |
92 environment variables need to be set. The first environment variable tells | |
93 the interpreter to load the <tt>compat-5.1.lua</tt> module at startup: </p> | |
94 | |
95 <pre class=example> | |
96 LUA_INIT=@<LDIR>/compat-5.1.lua | |
97 </pre> | |
98 | |
99 <p> | |
100 This is only need for Lua 5.0! Lua 5.1 comes with | |
101 the package system built in, of course. | |
102 </p> | |
103 | |
104 <p> | |
105 The other two environment variables instruct the compatibility module to | |
106 look for dynamic libraries and extension modules in the appropriate | |
107 directories and with the appropriate filename extensions. | |
108 </p> | |
109 | |
110 <pre class=example> | |
111 LUA_PATH=<LDIR>/?.lua;?.lua | |
112 LUA_CPATH=<CDIR>/?.dll;?.dll | |
113 </pre> | |
114 | |
115 <p> Again, naturally, on Unix systems the shared library extension would be | |
116 <tt>.so</tt> instead of <tt>.dll</tt>.</p> | |
117 | |
118 <h3>Using LuaSocket</h3> | |
119 | |
120 <p> With the above setup, and an interpreter with shared library support, | |
121 it should be easy to use LuaSocket. Just fire the interpreter and use the | |
122 <tt>require</tt> function to gain access to whatever module you need:</p> | |
123 | |
124 <pre class=example> | |
125 Lua 5.1.2 Copyright (C) 1994-2007 Lua.org, PUC-Rio | |
126 > socket = require("socket") | |
127 > print(socket._VERSION) | |
128 --> LuaSocket 2.0.2 | |
129 </pre> | |
130 | |
131 <p> Each module loads their dependencies automatically, so you only need to | |
132 load the modules you directly depend upon: </p> | |
133 | |
134 <pre class=example> | |
135 Lua 5.1.2 Copyright (C) 1994-2007 Lua.org, PUC-Rio | |
136 > http = require("socket.http") | |
137 > print(http.request("http://www.cs.princeton.edu/~diego/professional/luasocket")) | |
138 --> homepage gets dumped to terminal | |
139 </pre> | |
140 | |
141 <!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | |
142 | |
143 <div class=footer> | |
144 <hr> | |
145 <center> | |
146 <p class=bar> | |
147 <a href="home.html">home</a> · | |
148 <a href="home.html#down">download</a> · | |
149 <a href="installation.html">installation</a> · | |
150 <a href="introduction.html">introduction</a> · | |
151 <a href="reference.html">reference</a> | |
152 </p> | |
153 <p> | |
154 <small> | |
155 Last modified by Diego Nehab on <br> | |
156 Thu Apr 20 00:25:30 EDT 2006 | |
157 </small> | |
158 </p> | |
159 </center> | |
160 </div> | |
161 | |
162 </body> | |
163 </html> |