luasocket

LuaSocket socket/core.dll required location?

柔情痞子 提交于 2021-01-27 18:16:49
问题 When I use local socket = require("socket.core") It works fine, the dll is located at "dir/socket/core.dll" but when I move the dll to say "dir/folder/core.dll" and use local socket = require("folder.core.") It returns that it was found however it could not find the specific module in folder.core. How do I use Luasocket outside of it's socket.core requirements? Thanks! 回答1: If you want to require("socket.core") , the shared library (dll) has to have an exported function called luaopen_socket

How to check a socket is closed or not in luasocket library?

风格不统一 提交于 2020-01-13 09:47:48
问题 I am writing a server using Lua programming language, and the network layer is based on LuaSocket. And I cannot find any method to detect a socket is closed or not in its reference manual except by just try to read data from it(it will return nil and string 'close' when calling that). My code looks like this: local socket = require 'socket' local server = socket.tcp() local port = 9527 server:bind('*', port) local status, errorMessage = server:listen() if status == 1 then printf('Server is

LuaLanes and LuaSockets

匆匆过客 提交于 2019-12-30 18:43:09
问题 I'm working on a little Lua app (under Lua for Windows, if that matters) that uses sockets to communicate with the outside world. (LuaSocket) And I'm trying to make several requests in parallel. So I thought LuaLanes was the way to go. (I'm open to alternatives, of course, if there's a better solution, but would prefer not to deal with coroutines for this.) Something like this: server = assert (socket.bind ('*', 1234)) client = server : accept () -- set id to some unique value allClients [id]

Luasocket TCP stops listening after \r\n\r\n

拟墨画扇 提交于 2019-12-24 13:19:50
问题 Whenever I receive TCP messages using something like this: local socket=require "socket" local sv=socket.bind("*",1337) function love.update(dt) local s=sv:accept() while true do local s,e=s:receive() print(e or s) end end It works perfectly fine with \r\n spaced http headers, but when I try to http POST to it, I get the headers fine but not the data, witch is after and empty line (\r\n\r\n) it does the same thing when i use this as a client: s.socket_write(h,"test1\r\ntest2\r\n\r\ntest3") --

LuaSocket server:accept() timeout (TCP)

本秂侑毒 提交于 2019-12-21 18:29:31
问题 Problem Following LuaSocket Introduction I managed to get the server running. I also managed to connect from the client side. I noticed, however, that the server script freezes until server:accept() gets the connection. Research LuaSocket Reference specifies: Use the settimeout method or accept might block until another client shows up. This is even included in the example code. However, client:settimeout(10) is called after local client = server:accept() so the script gets blocked before it

Lua https timeout is not working

大憨熊 提交于 2019-12-20 05:16:08
问题 I am using following versions of Lua and it's packets on openWRT environment: luasocket-2.0.2 luasec-0.4 lua-5.1.4 Trying to use timeout for a https.request call. Tried using https.TIMEOUT where local https = require("ssl.https") and it never time outs. I tried giving a very small timeout (I know that I won't get answer in that time and internet connection is OK) also I tried when net connection is disconnected once https.request is called. Is it a known issue? or shall I try something else

Lua socket asynchronous calls

这一生的挚爱 提交于 2019-12-17 18:07:36
问题 I am writing a program that uses Lua socket to communicate with a http server. The API that I am using is "socket.http.request", and I have found that it is synchronous. My understanding is that it waits until it gets some response or time outs. Is my understanding correct? If so, I'd prefer to use an asynchronous API. I also found another API "socket.http.request_cb", which calls a call back function when the request is processed. However, it doesn't seem to work here. (This API is not

Error loading module (Lua)

旧时模样 提交于 2019-12-12 13:27:12
问题 I am having trouble with this error I am receiving whenever I run my application. The error is: loop or previous error loading module 'socket' . The code that is causing this error is: socket = require("socket") . This error occurs during the first lua_pcall . Here is the function that calls that: void startTerminal(int port, char host[80]) { lua_State *L = lua_open(); /* Open Lua Library */ luaL_openlibs(L); /* Choose the lua file that will run */ if(luaL_loadfile(L, "socket.lua")) { lfatal

SHOUTcast fetch request denied every time with 404

孤人 提交于 2019-12-11 04:20:42
问题 Code function radiotest(host,port) local rstr="Online" local sock, err = socket.tcp() if not sock then return "Failed" end sock:settimeout(1) local res, err = sock:connect(host, port) if not res then return "offline" else sock:settimeout(1) sock:send("GET /index.html HTTP/1.0\r\n UserAgent: SHOUTcast Song Status \r\n Accept: */*\r\n\r\n") sock:settimeout(3) local data=sock:receive('*a') sock:close() print(data) -- Further processing content here end end print( radiotest( "10.*.*.*", 1234 ) )

LuaSocket, Lua 5.2 and Redis

无人久伴 提交于 2019-12-10 13:49:19
问题 Has anyone been able to get these working together? I've gotten 5.2 working great, and it can find lua-redis (redis.lua), however it fails loading the socket module, which I can't seem to get working with lua (LuaSocket version 2.0.2). Anyone have any tips to get this working? I've tried making luasocket, however it fails completely, which I'm assuming is due to my lua version 5.2. Is the answer just to revert back to lua 5.1, or is there another fix that i'm not aware of? 回答1: The current