lua-nginx-module icon indicating copy to clipboard operation
lua-nginx-module copied to clipboard

feature: cosockets nonblocking listen accept feature

Open harijvs6 opened this issue 6 years ago • 9 comments

I hereby granted the copyright of the changes in this pull request to the authors of this lua-nginx-module project.

Dynamically listen/accept socket in lua. Sample usage

location = / {
    access_by_lua_block {
            local function log(client_sock)
                    local reader = client_sock:receive(8)
                    if not data then
                        ngx.say("failed to read the data stream: ", err)
                    end
                    client_sock:send("welcome")
            end
            local socket = ngx.socket.tcp()
            local id = ngx.worker.id()
            local server = socket:bind("127.0.0.1",9190 + id)
            server:listen()
            if not server then
                    ngx.say("error : ", err)
                    return
            end
            ngx.header["content-type"] = "text/html"
            local client_sock = server:accept()
            log(client_sock)
            server:close()
    }
}

harijvs6 avatar Oct 20 '18 19:10 harijvs6

This pull request is now in conflict :(

mergify[bot] avatar Jun 26 '20 00:06 mergify[bot]

@agentzh @spacewander Could you take a look at this and provide some high level feedback please

harijvs6 avatar Sep 26 '20 19:09 harijvs6

This pull request is now in conflict :(

mergify[bot] avatar Oct 10 '20 05:10 mergify[bot]

@harijvs6 hi, could you add some test cases for this PR?

rainingmaster avatar Oct 23 '20 06:10 rainingmaster