Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Lua bindings to anet library
C Lua
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lua/anet
src
test
.gitignore
README.markdown
TODO
anet-1.0-1.rockspec

README.markdown

LuaAnet - Lua bindings to anet library (from redis project)

Compilation

Use luarocks to compile and install:

$ [sudo] luarocks make

Usage:

require "anet"

local fd, err = anet.tcpserver(8080, "127.0.0.1")

while true do
    local clientfd, ip, port = anet.accept(fd, true, true)
    local n, msg = anet.read(clientfd, 4096)
    print("Read " .. n .. " bytes")

    if n > 0 then
        io.write(msg)
    elseif n < 0 then
        -- print error message
        print(msg)
        break
    elseif n == 0 then
        -- client closed connection
        anet.close(clientfd)
    end
end
Something went wrong with that request. Please try again.