Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

class method

BasicSocket.for_fd

BasicSocket.for_fd(fd) => basicsocket

Returns a socket object which contains the file descriptor, fd.

Example
# If invoked by inetd, STDIN/STDOUT/STDERR is a socket.
STDIN_SOCK = Socket.for_fd(STDIN.fileno)
p STDIN_SOCK.remote_address