class IO

Public Class Methods

socketpair(sync=true) click to toggle source
# File lib/chump.rb, line 24
def self.socketpair(sync=true)
  if UNIX
    one, two = UNIXSocket.socketpair
  else
    tcp = TCPServer.new('127.0.0.1', 0)
    one = TCPSocket.new('127.0.0.1', tcp.addr[1])
    two = tcp.accept and tcp.close
  end
  one.sync = two.sync = true if sync
  [one, two]
end