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
Loading
Please register or sign in to comment