lua-nginx-module
lua-nginx-module copied to clipboard
feature: cosockets nonblocking listen accept feature
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()
}
}
This pull request is now in conflict :(
@agentzh @spacewander Could you take a look at this and provide some high level feedback please
This pull request is now in conflict :(
@harijvs6 hi, could you add some test cases for this PR?