I'm a newb to LuaSocket, and I'm trying to program a cross-operating system terminal program that's basically just an IRC.
I'm expecting to have to set up a webserver that handles the TCP packets and sends them back to the clients, yet the LuaSocket documentation is so vague it's quite hard to get results.
...besides that, I have this extremely erroneous Lua/Ubuntu set up in which I can't even begin to get require("socket") to work.
If any Ubuntu users out there could help me with that part:
REDACTED@REDACTED-VPCCW21FX:~$ lua ~/Lua/main.lua
lua: /home/REDACTED/Lua/main.lua:2: module 'socket' not found:
no field package.preload['socket']
no file '/usr/local/share/lua/5.2/socket.lua'
no file '/usr/local/share/lua/5.2/socket/init.lua'
no file '/usr/local/lib/lua/5.2/socket.lua'
no file '/usr/local/lib/lua/5.2/socket/init.lua'
no file './socket.lua'
no file '/usr/local/lib/lua/5.2/socket.so'
no file '/usr/local/lib/lua/5.2/loadall.so'
no file './socket.so'
stack traceback:
[C]: in function 'require'
/home/REDACTED/Lua/main.lua:2: in main chunk
[C]: in ?
REDACTED@REDACTED-VPCCW21FX:~$
The contents of main.lua:
-- load namespace
local socket = require("socket")
-- create a TCP socket and bind it to the local host, at any port
local server = assert(socket.bind("*", 0))
-- find out which port the OS chose for us
local ip, port = server:getsockname()
-- print a message informing what's up
print("Please telnet to localhost on port " .. port)
print("After connecting, you have 10s to enter a line to be echoed")
-- loop forever waiting for clients
while 1 do
-- wait for a connection from any client
local client = server:accept()
-- make sure we don't block waiting for this client's line
client:settimeout(10)
-- receive the line
local line, err = client:receive()
-- if there was no error, send it back to the client
if not err then client:send(line .. "\n") end
-- done with client, close the object
client:close()
end
(this is from LuaSocket's documentation).
I have a TeamViewer, if anyone can help me with this that'd be great.
Both /usr/local/share/lua/5.2 and /usr/local/lib/lua/5.2 exist, but do not contain anything.
Yes, I have both lualib5.2-socket2 and luasocket installed.
So obviously the directory is empty and/or incorrect, but I have no idea how to fix it.
YET, keep the focal question mind: how would I go about programming the "IRC" I'd like?
I'm expecting to have to set up a webserver that handles the TCP packets and sends them back to the clients, yet the LuaSocket documentation is so vague it's quite hard to get results.
...besides that, I have this extremely erroneous Lua/Ubuntu set up in which I can't even begin to get require("socket") to work.
If any Ubuntu users out there could help me with that part:
REDACTED@REDACTED-VPCCW21FX:~$ lua ~/Lua/main.lua
lua: /home/REDACTED/Lua/main.lua:2: module 'socket' not found:
no field package.preload['socket']
no file '/usr/local/share/lua/5.2/socket.lua'
no file '/usr/local/share/lua/5.2/socket/init.lua'
no file '/usr/local/lib/lua/5.2/socket.lua'
no file '/usr/local/lib/lua/5.2/socket/init.lua'
no file './socket.lua'
no file '/usr/local/lib/lua/5.2/socket.so'
no file '/usr/local/lib/lua/5.2/loadall.so'
no file './socket.so'
stack traceback:
[C]: in function 'require'
/home/REDACTED/Lua/main.lua:2: in main chunk
[C]: in ?
REDACTED@REDACTED-VPCCW21FX:~$
The contents of main.lua:
-- load namespace
local socket = require("socket")
-- create a TCP socket and bind it to the local host, at any port
local server = assert(socket.bind("*", 0))
-- find out which port the OS chose for us
local ip, port = server:getsockname()
-- print a message informing what's up
print("Please telnet to localhost on port " .. port)
print("After connecting, you have 10s to enter a line to be echoed")
-- loop forever waiting for clients
while 1 do
-- wait for a connection from any client
local client = server:accept()
-- make sure we don't block waiting for this client's line
client:settimeout(10)
-- receive the line
local line, err = client:receive()
-- if there was no error, send it back to the client
if not err then client:send(line .. "\n") end
-- done with client, close the object
client:close()
end
(this is from LuaSocket's documentation).
I have a TeamViewer, if anyone can help me with this that'd be great.
Both /usr/local/share/lua/5.2 and /usr/local/lib/lua/5.2 exist, but do not contain anything.
Yes, I have both lualib5.2-socket2 and luasocket installed.
So obviously the directory is empty and/or incorrect, but I have no idea how to fix it.
YET, keep the focal question mind: how would I go about programming the "IRC" I'd like?