|
Packit |
b53373 |
|
|
Packit |
b53373 |
"http://www.w3.org/TR/html4/strict.dtd">
|
|
Packit |
b53373 |
<html>
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
<head>
|
|
Packit |
b53373 |
<meta name="description" content="LuaSocket: Introduction to the core">
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
Installation">
|
|
Packit |
b53373 |
<title>LuaSocket: Installation</title>
|
|
Packit |
b53373 |
<link rel="stylesheet" href="reference.css" type="text/css">
|
|
Packit |
b53373 |
</head>
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
<body>
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
<center>
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
Network support for the Lua language
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
home ·
|
|
Packit |
b53373 |
download ·
|
|
Packit |
b53373 |
installation ·
|
|
Packit |
b53373 |
introduction ·
|
|
Packit |
b53373 |
reference
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
</center>
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
Installation
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
Here we describe the standard distribution. If the
|
|
Packit |
b53373 |
standard doesn't meet your needs, we refer you to the Lua
|
|
Packit |
b53373 |
discussion list, where any question about the package scheme
|
|
Packit |
b53373 |
will likely already have been answered.
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
Directory structure
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
On Unix systems, the standard distribution uses two base
|
|
Packit |
b53373 |
directories, one for system dependent files, and another for system
|
|
Packit |
b53373 |
independent files. Let's call these directories <tt><CDIR></tt>
|
|
Packit |
b53373 |
and <tt><LDIR></tt>, respectively.
|
|
Packit |
b53373 |
For example, in my laptp, Lua 5.1 is configured to
|
|
Packit |
b53373 |
use '<tt>/usr/local/lib/lua/5.1</tt>' for
|
|
Packit |
b53373 |
<tt><CDIR></tt> and '<tt>/usr/local/share/lua/5.1</tt>' for
|
|
Packit |
b53373 |
<tt><LDIR></tt>. On Windows, <tt><CDIR></tt>
|
|
Packit |
b53373 |
usually points to the directory where the Lua executable is
|
|
Packit |
b53373 |
found, and <tt><LDIR></tt> points to a
|
|
Packit |
b53373 |
<tt>lua/</tt> directory inside <tt><CDIR></tt>. (These
|
|
Packit |
b53373 |
settings can be overridden by environment variables
|
|
Packit |
b53373 |
<tt>LUA_PATH</tt> and <tt>LUA_CPATH</tt>. See the Lua
|
|
Packit |
b53373 |
documentation for details.) Here is the standard LuaSocket
|
|
Packit |
b53373 |
distribution directory structure:
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
<LDIR>/ltn12.lua
|
|
Packit |
b53373 |
<LDIR>/socket.lua
|
|
Packit |
b53373 |
<CDIR>/socket/core.dll
|
|
Packit |
b53373 |
<LDIR>/socket/http.lua
|
|
Packit |
b53373 |
<LDIR>/socket/tp.lua
|
|
Packit |
b53373 |
<LDIR>/socket/ftp.lua
|
|
Packit |
b53373 |
<LDIR>/socket/smtp.lua
|
|
Packit |
b53373 |
<LDIR>/socket/url.lua
|
|
Packit |
b53373 |
<LDIR>/mime.lua
|
|
Packit |
b53373 |
<CDIR>/mime/core.dll
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
Naturally, on Unix systems, <tt>core.dll</tt>
|
|
Packit |
b53373 |
would be replaced by <tt>core.so</tt>.
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
Using LuaSocket
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
With the above setup, and an interpreter with shared library support,
|
|
Packit |
b53373 |
it should be easy to use LuaSocket. Just fire the interpreter and use the
|
|
Packit |
b53373 |
<tt>require</tt> function to gain access to whatever module you need:
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
Lua 5.2.2 Copyright (C) 1994-2013 Lua.org, PUC-Rio
|
|
Packit |
b53373 |
> socket = require("socket")
|
|
Packit |
b53373 |
> print(socket._VERSION)
|
|
Packit |
b53373 |
--> LuaSocket 3.0-rc1
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
Each module loads their dependencies automatically, so you only need to
|
|
Packit |
b53373 |
load the modules you directly depend upon:
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
Lua 5.2.2 Copyright (C) 1994-2013 Lua.org, PUC-Rio
|
|
Packit |
b53373 |
> http = require("socket.http")
|
|
Packit |
b53373 |
> print(http.request("http://www.impa.br/~diego/software/luasocket"))
|
|
Packit |
b53373 |
--> homepage gets dumped to terminal
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
<center>
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
home ·
|
|
Packit |
b53373 |
download ·
|
|
Packit |
b53373 |
installation ·
|
|
Packit |
b53373 |
introduction ·
|
|
Packit |
b53373 |
reference
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
<small>
|
|
Packit |
b53373 |
Last modified by Diego Nehab on
|
|
Packit |
b53373 |
Tue Jun 11 19:06:14 HKT 2013
|
|
Packit |
b53373 |
</small>
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
</center>
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
|
|
Packit |
b53373 |
</body>
|
|
Packit |
b53373 |
</html>
|