Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

UNIXSocket#send_io

unixsocket.send_io(io) => nil

Sends io as file descriptor passing.

Example
s1, s2 = UNIXSocket.pair

s1.send_io STDOUT
stdout = s2.recv_io

p STDOUT.fileno #=> 1
p stdout.fileno #=> 6

stdout.puts "hello" # outputs "hello\n" to standard output.

io may be any kind of IO object or integer file descriptor.

See also #recv_io #recvfrom also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0