[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: [ANN] Copas 2 scheduler release
- From: Thijs Schreijer <thijs@...>
- Date: Mon, 6 Apr 2015 12:23:40 +0000
All,
Copas is a dispatcher based on coroutines that can be used for asynchroneous networking. For example TCP or UDP based servers. But it also features timers and client support for http(s), ftp and smtp requests.
It uses LuaSocket as the interface with the TCP/IP stack and LuaSec for ssl support
I just tagged a new version of Copas in its Github repo. The new version has 2 main features;
- ssl support through LuaSec
- client support (http(s)/ftp/smtp). Notably; http(s) redirects across http <-> https
The complete list;
- Added: removeserver() function to remove servers from the scheduler (by Paul Kulchenko)
- Added: client requests for http(s), ftp, and smtp (like LuaSocket/LuaSec, but async)
- Added: transparent async support (handshake, and send/receive) for ssl using LuaSec
- Added: handler() as a convenience for full copas and ssl wrapping
- [breaking] Change: the loop now exits when there is nothing more to do
- [breaking] Change: dummy first argument to new tasks removed
- Fixed: completed the socket wrappers, missing functions were added
- Fixed: connect issue, step() errorring out instead of returning nil + error
- Fixed: UDP sockets being auto closed
- Fixed: the receivePartial function for http request support (by Paul Kulchenko)
Though I don't expect the 2 breaking changes to have any impact or break anything. I bumped to 2.0 anyway, just in case.
The code is available in the github repo, not yet through LuaRocks due to some upload issues.
Sample for an ssl based server (top of mind, so untested);
local sslparams = {
-- see LuaSec for parameter format
}
local handler = function(skt)
-- skt will be wrapped in both copas and ssl manner, and the ssl handshake has been completed here
while true
-- do the regular skt:send() and skt:receive() stuff here
end
end
server = socket.bind(host, port)
copas.addserver(server, copas.handler(handler, sslparams))
copas.loop()
Enjoy,
Thijs