luasocket

How could I embedded socket in Lua internally, just like oslib, debuglib?

落爺英雄遲暮 提交于 2019-12-05 17:57:06
I want to implement the function like embedding the socket function in my Lua build. So I don't need to copy socket.core.dll any more (just for fun). I search the maillist, and see some guys discuss the topic, http://lua-users.org/lists/lua-l/2005-10/msg00269.html But I have question for the details steps, who could give me a detailed steps for changing the lua and luasocket code to make them work together (not with dll method). I tried these steps in windows xp with VC2008: 1) copy luasocket code to Lua project. 2) add some code static const luaL_Reg lualibs[] = { {"", luaopen_base}, {LUA

LuaSocket server:accept() timeout (TCP)

≯℡__Kan透↙ 提交于 2019-12-05 14:18:07
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 reaches this point. I read that this could be worked around by multithreading but this seems to be an

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

眉间皱痕 提交于 2019-12-05 11:07:35
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 launched successfully on port %u', port) else printf('Server listen failed, error message is %s',

cocos2dx3.4 lua整合protobuf

大城市里の小女人 提交于 2019-12-05 10:22:31
网上看了一些资料但还是遇到不少问题。在这里记录一下 下载地址: https://github.com/sean-lin/protoc-gen-lua.git 1. 复制文件 protoc-gen-lua/protobuf/pb.c 到 frameworks\cocos2d-x\external\lua\protobuf\pb.c 2. 修改 frameworks\cocos2d-x\cocos\scripting\lua-bindings\manual\network\lua_extensions.c 文件 #include "lua_extensions.h" #if __cplusplus extern "C" { #endif // socket #include "protobuf/pb.c" #include "luasocket/luasocket.h" #include "luasocket/luasocket_scripts.h" #include "luasocket/mime.h" static luaL_Reg luax_exts[] = { {"socket.core", luaopen_socket_core}, {"mime.core", luaopen_mime_core}, {NULL, NULL} }; void luaopen_lua

lua http socket timeout

家住魔仙堡 提交于 2019-12-05 05:45:14
The LuaSocket HTTP module documentation says that a timeout can be set on a HTTP connection: The following constants can be set to control the default behavior of the HTTP module: PORT: default port used for connections; PROXY: default proxy used for connections; TIMEOUT: sets the timeout for all I/O operations; USERAGENT: default user agent reported to server. http://w3.impa.br/~diego/software/luasocket/http.htm How do I set these constants in a lua script? You can do this to set a timeout for one request instead of the entire HTTP module: local socket = require "socket" local http = require

How to download a file in Lua, but write to a local file as it works

我们两清 提交于 2019-12-04 08:20:33
I'm trying to make an updater so when my Lua application is out-of-date it will use LuaSocket to download the newer .exe file (which can run my Lua code). Inside this updater, I want it to show how much has been downloaded so far. However, with the following HTTP request, it blocks the application until downloaded fully: local b, c, h = http.request("https://www.example.com/Download/Example.exe?from="..Game.Version) I am using threads to download it, however I still cannot write to the file until the download is complete inside of the thread, thus the progress bar will go 0%, 100%, without

Error requiring luasocket on socket.core file installed through Luarocks on Windows

混江龙づ霸主 提交于 2019-12-04 06:47:40
问题 System configuration: OS: Windows 7 x64 lua -v Lua 5.1.4 luarocks -v 2.2.0beta1 luarocks list luasocket 3.0rc1-1 (installed) - C:/Program Files (x86)/LuaRocks/systree/lib/luarocks/rocks luarocks show luasocket LuaSocket 3.0rc1-1 - Network support for the Lua language LuaSocket is a Lua extension library that is composed by two parts: a C core that provides support for the TCP and UDP transport layers, and a set of Lua modules that add support for functionality commonly needed by applications

https request in lua

喜夏-厌秋 提交于 2019-12-03 09:12:58
问题 I am trying to retrieve a page on my SSL enabled server with a lua script. Important to note that the server has a self-signed certificate. No problem with certificate issued by a trusted CA. local https = require("socket.http") local resp = {} local r, c, h, s = https.request{ url = "https://my-server:443/example.php", sink = ltn12.sink.table(resp), protocol = "tlsv1" } The server returns: Bad Request Your browser sent a request that this server could not understand. Reason: You're speaking

Error requiring luasocket on socket.core file installed through Luarocks on Windows

匿名 (未验证) 提交于 2019-12-03 02:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: System configuration: OS: Windows 7 x64 lua -v Lua 5.1.4 luarocks -v 2.2.0beta1 luarocks list luasocket 3.0rc1-1 (installed) - C:/Program Files (x86)/LuaRocks/systree/lib/luarocks/rocks luarocks show luasocket LuaSocket 3.0rc1-1 - Network support for the Lua language LuaSocket is a Lua extension library that is composed by two parts: a C core that provides support for the TCP and UDP transport layers, and a set of Lua modules that add support for functionality commonly needed by applications that deal with the Internet. License: MIT Homepage

luaSocket HTTP requests always respond with a redirect (301 or 302)

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I use LuaForWindows (latest version) and I have read this and this answer and everything i could find in the mailinglist of lua-users.org. What ever I try (most) sites only respond with either 301 or 302. I have created an example batch script which downloads (some) of the OpenGL 2.1 Reference from their man pages. @ECHO OFF FOR /F "SKIP=5" %%# IN ( %~fs0 ) DO lua -l socket.http -e "print(socket.http.request('https://www.opengl.org/sdk/docs/man2/xhtml/%%#.xml'))" GOTO:EOF glAccum glActiveTexture glAlphaFunc glAreTexturesResident