| 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 |
|
| 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="index.html">home</a> · |
| 29 |
<a href="index.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 |
|
| 39 |
|
| 40 |
<h2>Installation</h2> |
| 41 |
|
| 42 |
<p> Here we describe the standard distribution. If the |
| 43 |
standard doesn't meet your needs, we refer you to the Lua |
| 44 |
discussion list, where any question about the package scheme |
| 45 |
will likely already have been answered. </p> |
| 46 |
|
| 47 |
<h3>Directory structure</h3> |
| 48 |
|
| 49 |
<p> On Unix systems, the standard distribution uses two base |
| 50 |
directories, one for system dependent files, and another for system |
| 51 |
independent files. Let's call these directories <tt><CDIR></tt> |
| 52 |
and <tt><LDIR></tt>, respectively. |
| 53 |
For example, in my laptp, Lua 5.1 is configured to |
| 54 |
use '<tt>/usr/local/lib/lua/5.1</tt>' for |
| 55 |
<tt><CDIR></tt> and '<tt>/usr/local/share/lua/5.1</tt>' for |
| 56 |
<tt><LDIR></tt>. On Windows, <tt><CDIR></tt> |
| 57 |
usually points to the directory where the Lua executable is |
| 58 |
found, and <tt><LDIR></tt> points to a |
| 59 |
<tt>lua/</tt> directory inside <tt><CDIR></tt>. (These |
| 60 |
settings can be overridden by environment variables |
| 61 |
<tt>LUA_PATH</tt> and <tt>LUA_CPATH</tt>. See the Lua |
| 62 |
documentation for details.) Here is the standard LuaSocket |
| 63 |
distribution directory structure:</p> |
| 64 |
|
| 65 |
<pre class=example> |
| 66 |
<LDIR>/ltn12.lua |
| 67 |
<LDIR>/socket.lua |
| 68 |
<CDIR>/socket/core.dll |
| 69 |
<LDIR>/socket/http.lua |
| 70 |
<LDIR>/socket/tp.lua |
| 71 |
<LDIR>/socket/ftp.lua |
| 72 |
<LDIR>/socket/smtp.lua |
| 73 |
<LDIR>/socket/url.lua |
| 74 |
<LDIR>/mime.lua |
| 75 |
<CDIR>/mime/core.dll |
| 76 |
</pre> |
| 77 |
|
| 78 |
<p> Naturally, on Unix systems, <tt>core.dll</tt> |
| 79 |
would be replaced by <tt>core.so</tt>. |
| 80 |
</p> |
| 81 |
|
| 82 |
<h3>Using LuaSocket</h3> |
| 83 |
|
| 84 |
<p> With the above setup, and an interpreter with shared library support, |
| 85 |
it should be easy to use LuaSocket. Just fire the interpreter and use the |
| 86 |
<tt>require</tt> function to gain access to whatever module you need:</p> |
| 87 |
|
| 88 |
<pre class=example> |
| 89 |
Lua 5.2.2 Copyright (C) 1994-2013 Lua.org, PUC-Rio |
| 90 |
> socket = require("socket") |
| 91 |
> print(socket._VERSION) |
| 92 |
--> LuaSocket 3.0-rc1 |
| 93 |
</pre> |
| 94 |
|
| 95 |
<p> Each module loads their dependencies automatically, so you only need to |
| 96 |
load the modules you directly depend upon: </p> |
| 97 |
|
| 98 |
<pre class=example> |
| 99 |
Lua 5.2.2 Copyright (C) 1994-2013 Lua.org, PUC-Rio |
| 100 |
> http = require("socket.http") |
| 101 |
> print(http.request("http://www.impa.br/~diego/software/luasocket")) |
| 102 |
--> homepage gets dumped to terminal |
| 103 |
</pre> |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
<div class=footer> |
| 108 |
<hr> |
| 109 |
<center> |
| 110 |
<p class=bar> |
| 111 |
<a href="index.html">home</a> · |
| 112 |
<a href="index.html#down">download</a> · |
| 113 |
<a href="installation.html">installation</a> · |
| 114 |
<a href="introduction.html">introduction</a> · |
| 115 |
<a href="reference.html">reference</a> |
| 116 |
</p> |
| 117 |
<p> |
| 118 |
<small> |
| 119 |
Last modified by Diego Nehab on <br> |
| 120 |
Tue Jun 11 19:06:14 HKT 2013 |
| 121 |
</small> |
| 122 |
</p> |
| 123 |
</center> |
| 124 |
</div> |
| 125 |
|
| 126 |
</body> |
| 127 |
</html> |