-
Notifications
You must be signed in to change notification settings - Fork 635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change. socket:setfd() set fd
to invalid value.
#54
base: master
Are you sure you want to change the base?
Conversation
Change. socket:setfd return previews `fd` value. Change. socket.tcp and socket.udp can create object based on `fd`. Add. test setfd ```lua ---- server cli = assert(srv:accept()) -- test if worker thread take ownership and clear `fd` if run_worker_thread(cli:getfd()) then cli:setfd() end cli:close() ---- worker -- wrap raw `fd` to socket object local sock = socket.tcp(..., "client") -- do work with sock object ```
This change no longer lines up with master, and it's not obvious to me that it should be made to. Can it be either resolved or closed? |
Not sure what this was trying to solve. |
The main idea for this PR is allow to pass socket to the separate LuaVM (e.g. in separate os thread) and create clien socket in there. |
@moteus I think this is a useful change. I know this has been open like forever, but would you mind rebasing it on |
I think that adding a string as option to these functions will prevent future extensions, if there are any. Should there be an options table instead? |
tcp->sock = (t_socket) luaL_checknumber(L, 2); | ||
return 0; | ||
t_socket fd = tcp->sock; | ||
if(lua_gettop(L) == 1) tcp->sock = SOCKET_INVALID; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than gettop
I think you'd want a lua_isnoneornil
check.
This is alternative to
acceptfd
method.Change. socket:setfd() set
fd
to invalid value.Change. socket:setfd return previews
fd
value.Change. socket.tcp and socket.udp can create object based on
fd
.Add. test setfd