Skip to content
Snippets Groups Projects
Commit 5304087c authored by Vladimir Davydov's avatar Vladimir Davydov Committed by Vladimir Davydov
Browse files

lua/socket: introduce socket.from_fd

The new function constructs a socket object from a file descriptor
number. No checks are performed on the given fd so the user may pass
a closed fd or a fd that refers to a file, in which case the socket
object methods will fail and/or work not as expected.

It may be useful for creating a socket object from a file descriptor
inherited from a parent process.

The only tricky part here is setting the socket itype, which is used
for setting the correct receive buffer size for datagram sockets, see
commit 11fb3ab9 ("socket: evaluate buffer size in recv / recvfrom").
On error the itype is silently set to 0.

Part of #8927

NO_DOC=later
NO_CHANGELOG=later
parent 3fccfc8f
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment