Questions tagged [luasocket]

LuaSocket is a Lua extension library that helps to add support for functionality commonly needed by applications that deal with the Internet. It provides easy access to TCP, UDP, DNS, SMTP, FTP, HTTP, MIME and more.

LuaSocket is a 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.

Author: Diego Nehab

The core support has been implemented so that it is both efficient and simple to use. It is available to any Lua application once it has been properly initialized by the interpreter in use. The code has been tested and runs well on several Windows and Unix platforms.

Among the support modules, the most commonly used implement the SMTP (sending e-mails), HTTP (WWW access) and FTP (uploading and downloading files) client protocols. These provide a very natural and generic interface to the functionality defined by each protocol. In addition, you will find that the MIME (common encodings), URL (anything you could possible want to do with one) and LTN12 (filters, sinks, sources and pumps) modules can be very handy.

Useful Links

178 questions
18
votes
4 answers

https request in lua

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 =…
ripat
  • 3,076
  • 6
  • 26
  • 38
13
votes
3 answers

Lua socket asynchronous calls

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…
Vicky
  • 1,379
  • 6
  • 18
  • 29
11
votes
2 answers

lua http socket timeout

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…
ripat
  • 3,076
  • 6
  • 26
  • 38
11
votes
2 answers

Installing Lua socket library

Either I'm overtired or blind. I want to learn networking with Lua and therefore I have to install the socket lib, so I can require it easily, but I don't know, which files I should "require". The example says: local socket = require("socket") but…
user1248569
  • 121
  • 1
  • 1
  • 3
10
votes
2 answers

How to use Lua 5.2 with luasocket 3

I am trying to compile luasocket 3 that I found on GitHub with lua 5.2. Problem is, I'm not sure how to bind together Lua with luasocket. Do I need to compile luasocket as DLL and then reference if somewhere in lua code, or should I just call it…
miller
  • 1,636
  • 3
  • 26
  • 55
8
votes
2 answers

“module 'socket.http' not found:” --Lua on iMac

When I run my code in terminal, I get this error/message: module 'socket.http' not found: no field package.preload['socket.http'] no file '/usr/local/share/lua/5.2/socket/http.lua' no file…
Alex
  • 1,035
  • 3
  • 16
  • 31
7
votes
2 answers

How do I deal with Lua libraries that don't coroutine.yield()?

I want to download a large file and concurrently handle other things. However, luasocket.http never calls coroutine.yield(). Everything else freezes while the file downloads. Here's an illustrative example, in which I try to simultaneously download…
7
votes
2 answers

LuaLanes and LuaSockets

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…
Cyclonus
  • 507
  • 5
  • 13
6
votes
2 answers

Get HTTPS page content with Lua

I'm trying to access the contents of a webpage from my lua code. The following code works for non-HTTPS pages local http=require("socket.http") body,c,l,h = http.request("http://www.example.com:443") print("status line",l) print("body",body) But…
John Boga
  • 484
  • 6
  • 14
6
votes
1 answer

LuaSocket server:accept() timeout (TCP)

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…
Siemkowski
  • 1,351
  • 5
  • 15
  • 32
6
votes
3 answers

Luasocket + nginx error - lua entry thread aborted: runtime error: attempt to yield across C-call boundary

When I use the following script: local smtp = require("socket.smtp") local from = "from@host" local rcpt = "rcpt@host" local msg = { headers = { to = rcpt, subject = "Hi" }, body = "Hello" } smtp.send{from = from,rcpt = rcpt,source =…
user479947
6
votes
1 answer

Installation of luasocket using luarocks

I installed luarocks in my windows xp(32 bit) system following instructions available on http://luarocks.org/en/Installation_instructions_for_Windows to install luasocket from luarocks I used command "luarocks install luasocket" in command prompt.…
Ankur Gupta
  • 61
  • 1
  • 3
6
votes
1 answer

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

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…
moligaloo
  • 1,083
  • 13
  • 27
5
votes
1 answer

LuaSocket, Lua 5.2 and Redis

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…
Jonathan Coe
  • 1,485
  • 4
  • 18
  • 36
5
votes
1 answer

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

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…
tDwtp
  • 480
  • 5
  • 12
1
2 3
11 12