class Rendezvous::Socket::CustomSocket

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/rendezvous/socket/custom_socket.rb, line 6
def initialize
  super(AF_INET, SOCK_STREAM, 0)
  setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
  if defined?(SO_REUSEPORT)
    setsockopt(SOL_SOCKET, SO_REUSEPORT, 1)
  end
end

Public Instance Methods

accept() click to toggle source
Calls superclass method
# File lib/rendezvous/socket/custom_socket.rb, line 38
def accept
  $stderr.puts "attempting to accept" if $DEBUG
  super[0]
end
accept_nonblock() click to toggle source
Calls superclass method
# File lib/rendezvous/socket/custom_socket.rb, line 43
def accept_nonblock
  $stderr.puts "attempting to accept_nonblock" if $DEBUG
  super[0]
end
addr() click to toggle source
# File lib/rendezvous/socket/custom_socket.rb, line 48
def addr
  ::Socket.unpack_sockaddr_in(getsockname)
end
bind(port = 0) click to toggle source
Calls superclass method
# File lib/rendezvous/socket/custom_socket.rb, line 19
def bind(port = 0)
  ip = ::Socket.ip_address_list.detect{|a| a.ipv4_private? }.ip_address
  $stderr.puts "attempting to bind to #{ip}:#{port}" if $DEBUG
  addr_local = ::Socket.pack_sockaddr_in(port, ip)
  super(addr_local)
end
connect(ip, port) click to toggle source
Calls superclass method
# File lib/rendezvous/socket/custom_socket.rb, line 26
def connect(ip, port)
  $stderr.puts "attempting to connect to #{ip}:#{port}" if $DEBUG
  addr_remote = ::Socket.pack_sockaddr_in(port, ip)
  super(addr_remote)
end
connect_nonblock(ip, port) click to toggle source
Calls superclass method
# File lib/rendezvous/socket/custom_socket.rb, line 32
def connect_nonblock(ip, port)
  $stderr.puts "attempting to connect_nonblock to #{ip}:#{port}" if $DEBUG
  addr_remote = ::Socket.pack_sockaddr_in(port, ip)
  super(addr_remote)
end
listen(buf) click to toggle source
Calls superclass method
# File lib/rendezvous/socket/custom_socket.rb, line 14
def listen(buf)
  $stderr.puts "attempting to listen" if $DEBUG
  super(buf)
end
local_port() click to toggle source
# File lib/rendezvous/socket/custom_socket.rb, line 52
def local_port
  addr[0]
end