First, download, install
1.1 Download
FileName: luasocket-2.0.2.tar.gz
Download Address: Http://files.luaforge.net/releases/luasocket/luasocket
http://luaforge.net/projects/
GitHub Source Download: Https://github.com/diegonehab/luasocket
1.2 Installation
Tar zxvf luasocket-2.0.2.tar.gz
Modify configuration config (see 1.3)
Make
Make install
1.3 Modifying Config file config
luainc=-i/usr/local/luajit/include/luajit-2.1
install_top_share=/usr/local/luajit/share/lua/5.1
install_top_lib=/usr/local/luajit/lib/lua/5.1
Depending on your own installation of the LUA path, I am the installed Luajit.
Second, the example code
Use Luasocket to get the host name.
2.1 Code
Package.path = '/usr/local/luajit/share/lua/5.1/? Lua; '
Package.cpath = '/usr/local/luajit/lib/lua/5.1/? So; '
Local socket = require ("socket")
print (Socket.dns.gethostname ())
2.2 Running Results
Resources:
Small trial luasocket:http://www.360doc.com/content/14/0919/15/15077656_410715083.shtml