mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-12-27 04:48:21 +01:00
164 lines
4.9 KiB
HTML
164 lines
4.9 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
|
"http://www.w3.org/TR/html4/strict.dtd">
|
|
<html>
|
|
|
|
<head>
|
|
<meta name="description" content="LuaSocket: Introduction to the core">
|
|
<meta name="keywords" content="Lua, LuaSocket, TCP, UDP, Network, Support,
|
|
Installation">
|
|
<title>LuaSocket: Installation</title>
|
|
<link rel="stylesheet" href="reference.css" type="text/css">
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<!-- header +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
|
|
|
<div class=header>
|
|
<hr>
|
|
<center>
|
|
<table summary="LuaSocket logo">
|
|
<tr><td align=center><a href="http://www.lua.org">
|
|
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
|
|
</a></td></tr>
|
|
<tr><td align=center valign=top>Network support for the Lua language
|
|
</td></tr>
|
|
</table>
|
|
<p class=bar>
|
|
<a href="home.html">home</a> ·
|
|
<a href="home.html#download">download</a> ·
|
|
<a href="installation.html">installation</a> ·
|
|
<a href="introduction.html">introduction</a> ·
|
|
<a href="reference.html">reference</a>
|
|
</p>
|
|
</center>
|
|
<hr>
|
|
</div>
|
|
|
|
<!-- installation ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
|
|
|
<h2>Installation</h2>
|
|
|
|
<p> LuaSocket 2.0.1 uses the new package system for Lua 5.1.
|
|
All Lua library developers are encouraged to update their libraries so that
|
|
all libraries can coexist peacefully and users can benefit from the
|
|
standardization and flexibility of the standard.
|
|
</p>
|
|
|
|
<p>
|
|
Those stuck with Lua 5.0 will need the
|
|
<a href=http://www.keplerproject.org/compat/>compat-5.1</a>
|
|
module. It is maintained by
|
|
<a href=http://www.keplerproject.org/>The Kepler
|
|
Project</a>'s team, and implements the Lua 5.1 package proposal
|
|
on top of Lua 5.0. </p>
|
|
|
|
<p> Here we will only describe the standard distribution.
|
|
If the standard doesn't meet your needs, we refer you to the
|
|
Lua discussion list, where any question about the package
|
|
scheme will likely already have been answered. </p>
|
|
|
|
<h3>Directory structure</h3>
|
|
|
|
<p> On Unix systems, the standard distribution uses two base
|
|
directories, one for system dependent files, and another for system
|
|
independent files. Let's call these directories <tt><CDIR></tt>
|
|
and <tt><LDIR></tt>, respectively.
|
|
For instance, in my laptop, I use '<tt>/usr/local/lib/lua/5.0</tt>' for
|
|
<tt><CDIR></tt> and '<tt>/usr/local/share/lua/5.0</tt>' for
|
|
<tt><LDIR></tt>. On Windows, sometimes only one directory is used, say
|
|
'<tt>c:\program files\lua\5.0</tt>'. Here is the standard LuaSocket
|
|
distribution directory structure:</p>
|
|
|
|
<pre class=example>
|
|
<LDIR>/compat-5.1.lua
|
|
<LDIR>/ltn12.lua
|
|
<LDIR>/socket.lua
|
|
<CDIR>/socket/core.dll
|
|
<LDIR>/socket/http.lua
|
|
<LDIR>/socket/tp.lua
|
|
<LDIR>/socket/ftp.lua
|
|
<LDIR>/socket/smtp.lua
|
|
<LDIR>/socket/url.lua
|
|
<LDIR>/mime.lua
|
|
<CDIR>/mime/core.dll
|
|
</pre>
|
|
|
|
<p> Naturally, on Unix systems, <tt>core.dll</tt>
|
|
would be replaced by <tt>core.so</tt>.
|
|
</p>
|
|
|
|
<p> In order for the interpreter to find all LuaSocket components, three
|
|
environment variables need to be set. The first environment variable tells
|
|
the interpreter to load the <tt>compat-5.1.lua</tt> module at startup: </p>
|
|
|
|
<pre class=example>
|
|
LUA_INIT=@<LDIR>/compat-5.1.lua
|
|
</pre>
|
|
|
|
<p>
|
|
This is only need for Lua 5.0! Lua 5.1 comes with
|
|
the package system bult in, of course.
|
|
</p>
|
|
|
|
<p>
|
|
The other two environment variables instruct the compatibility module to
|
|
look for dynamic libraries and extension modules in the appropriate
|
|
directories and with the appropriate filename extensions.
|
|
</p>
|
|
|
|
<pre class=example>
|
|
LUA_PATH=<LDIR>/?.lua;?.lua
|
|
LUA_CPATH=<CDIR>/?.dll;?.dll
|
|
</pre>
|
|
|
|
<p> Again, naturally, on Unix systems the shared library extension would be
|
|
<tt>.so</tt> instead of <tt>.dll</tt>.</p>
|
|
|
|
<h3>Using LuaSocket</h3>
|
|
|
|
<p> With the above setup, and an interpreter with shared library support,
|
|
it should be easy to use LuaSocket. Just fire the interpreter and use the
|
|
<tt>require</tt> function to gain access to whatever module you need:</p>
|
|
|
|
<pre class=example>
|
|
Lua 5.0.2 Copyright (C) 1994-2004 Tecgraf, PUC-Rio
|
|
> socket = require("socket")
|
|
> print(socket._VERSION)
|
|
--> LuaSocket 2.0.1
|
|
</pre>
|
|
|
|
<p> Each module loads their dependencies automatically, so you only need to
|
|
load the modules you directly depend upon: </p>
|
|
|
|
<pre class=example>
|
|
Lua 5.0.2 Copyright (C) 1994-2004 Tecgraf, PUC-Rio
|
|
> http = require("socket.http")
|
|
> print(http.request("http://www.cs.princeton.edu/~diego/professional/luasocket"))
|
|
--> homepage gets dumped to terminal
|
|
</pre>
|
|
|
|
<!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
|
|
|
<div class=footer>
|
|
<hr>
|
|
<center>
|
|
<p class=bar>
|
|
<a href="home.html">home</a> ·
|
|
<a href="home.html#down">download</a> ·
|
|
<a href="installation.html">installation</a> ·
|
|
<a href="introduction.html">introduction</a> ·
|
|
<a href="reference.html">reference</a>
|
|
</p>
|
|
<p>
|
|
<small>
|
|
Last modified by Diego Nehab on <br>
|
|
Mon Nov 21 01:57:22 EST 2005
|
|
</small>
|
|
</p>
|
|
</center>
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|