Install Lua Socket Library

Either I'm overworked or blind. I want to learn how to network with Lua, and therefore I need to install socketlib, so I can require it easily, but I don’t know which files I should “require”. This example says:

local socket = require("socket")

but, as I said, I do not know what files should I turn if I use socket.lua, it does not work, and I get: No files found.

I got lib from here: Download Lua Sockets

Or is there any other way to install the lib socket?

+5
source share
2 answers

require Lua , , . Lua. , package.path package.cpath.

package.path: , Lua- ( .lua)
package.cpath: , require C- (.so/.dll modules)

, :

print(package.path..'\n'..package.cpath)

LuaSocket , Lua .

require. , LuaSocket libs :

Project
|
> libs
     |
     > lua
         |
         > socket         
     > socket
     > mime

, require ( /?.dll /?.so Linux):

package.path = package.path..';./libs/lua/?.lua'
package.cpath = package.cpath..';./libs/socket/?.dll;./libs/mime/?.dll'
local socket = require 'socket'
+12

Linux-:

#luarocks install luasocket

, CONFIGURATION

#luarocks 

linux (.: ):

$lua 
> socket = require ("socket")

:

> socket = require 'socket'
0

All Articles