2004-11-28 09:17:16 +01:00
|
|
|
<!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">
|
2004-12-13 07:26:01 +01:00
|
|
|
<title>LuaSocket: Installation</title>
|
2004-11-28 09:17:16 +01:00
|
|
|
<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>
|
2009-05-27 11:31:38 +02:00
|
|
|
<a href="index.html">home</a> ·
|
|
|
|
<a href="index.html#download">download</a> ·
|
2004-12-13 07:26:01 +01:00
|
|
|
<a href="installation.html">installation</a> ·
|
2004-11-28 09:17:16 +01:00
|
|
|
<a href="introduction.html">introduction</a> ·
|
|
|
|
<a href="reference.html">reference</a>
|
|
|
|
</p>
|
|
|
|
</center>
|
|
|
|
<hr>
|
|
|
|
</div>
|
|
|
|
|
2004-12-13 07:26:01 +01:00
|
|
|
<!-- installation ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
2004-11-28 09:17:16 +01:00
|
|
|
|
2005-11-21 08:04:44 +01:00
|
|
|
<h2>Installation</h2>
|
2004-11-28 09:17:16 +01:00
|
|
|
|
2012-04-16 19:15:26 +02:00
|
|
|
<p> Here we 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>
|
2004-11-28 09:17:16 +01:00
|
|
|
|
|
|
|
<h3>Directory structure</h3>
|
|
|
|
|
2005-09-29 08:11:42 +02:00
|
|
|
<p> On Unix systems, the standard distribution uses two base
|
|
|
|
directories, one for system dependent files, and another for system
|
2005-11-22 21:51:28 +01:00
|
|
|
independent files. Let's call these directories <tt><CDIR></tt>
|
|
|
|
and <tt><LDIR></tt>, respectively.
|
2012-04-16 19:15:26 +02:00
|
|
|
For example, in my laptp, Lua 5.1 is configured to
|
|
|
|
use '<tt>/usr/local/lib/lua/5.1</tt>' for
|
|
|
|
<tt><CDIR></tt> and '<tt>/usr/local/share/lua/5.1</tt>' for
|
|
|
|
<tt><LDIR></tt>. On Windows, <tt><CDIR></tt>
|
|
|
|
usually points to the directory where the Lua executable is
|
|
|
|
found, and <tt><LDIR></tt> points to a
|
|
|
|
<tt>lua/</tt> directory inside <tt><CDIR></tt>. (These
|
|
|
|
settings can be overridden by environment variables
|
|
|
|
<tt>LUA_PATH</tt> and <tt>LUA_CPATH</tt>. See the Lua
|
|
|
|
documentation for details.) Here is the standard LuaSocket
|
2005-09-29 08:11:42 +02:00
|
|
|
distribution directory structure:</p>
|
2004-11-28 09:17:16 +01:00
|
|
|
|
|
|
|
<pre class=example>
|
2005-11-22 21:51:28 +01:00
|
|
|
<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
|
2004-11-28 09:17:16 +01:00
|
|
|
</pre>
|
|
|
|
|
2005-08-12 07:56:32 +02:00
|
|
|
<p> Naturally, on Unix systems, <tt>core.dll</tt>
|
2006-04-20 06:16:23 +02:00
|
|
|
would be replaced by <tt>core.so</tt>.
|
2005-10-05 05:16:17 +02:00
|
|
|
</p>
|
2004-11-28 09:17:16 +01:00
|
|
|
|
|
|
|
<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>
|
2013-06-11 13:10:03 +02:00
|
|
|
Lua 5.2.2 Copyright (C) 1994-2013 Lua.org, PUC-Rio
|
2004-11-28 09:17:16 +01:00
|
|
|
> socket = require("socket")
|
2005-09-29 08:11:42 +02:00
|
|
|
> print(socket._VERSION)
|
2022-03-28 13:53:32 +02:00
|
|
|
--> LuaSocket 3.0.0
|
2004-11-28 09:17:16 +01:00
|
|
|
</pre>
|
|
|
|
|
|
|
|
<p> Each module loads their dependencies automatically, so you only need to
|
2005-11-21 08:04:44 +01:00
|
|
|
load the modules you directly depend upon: </p>
|
2004-11-28 09:17:16 +01:00
|
|
|
|
|
|
|
<pre class=example>
|
2013-06-11 13:10:03 +02:00
|
|
|
Lua 5.2.2 Copyright (C) 1994-2013 Lua.org, PUC-Rio
|
2004-11-28 09:17:16 +01:00
|
|
|
> http = require("socket.http")
|
2012-04-16 19:15:26 +02:00
|
|
|
> print(http.request("http://www.impa.br/~diego/software/luasocket"))
|
2004-11-28 09:17:16 +01:00
|
|
|
--> homepage gets dumped to terminal
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
<!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
|
|
|
|
|
|
|
<div class=footer>
|
|
|
|
<hr>
|
|
|
|
<center>
|
|
|
|
<p class=bar>
|
2009-05-27 11:31:38 +02:00
|
|
|
<a href="index.html">home</a> ·
|
|
|
|
<a href="index.html#down">download</a> ·
|
2004-12-13 07:26:01 +01:00
|
|
|
<a href="installation.html">installation</a> ·
|
2004-11-28 09:17:16 +01:00
|
|
|
<a href="introduction.html">introduction</a> ·
|
|
|
|
<a href="reference.html">reference</a>
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
<small>
|
|
|
|
Last modified by Diego Nehab on <br>
|
2013-06-11 13:10:03 +02:00
|
|
|
Tue Jun 11 19:06:14 HKT 2013
|
2004-11-28 09:17:16 +01:00
|
|
|
</small>
|
|
|
|
</p>
|
|
|
|
</center>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|