module DatTCP::Server::TCPServer
Public Class Methods
build(*args)
click to toggle source
# File lib/dat-tcp.rb, line 184 def self.build(*args) case args.size when 2 self.new(*args) when 1 self.for_fd(*args) end end
configure(tcp_server)
click to toggle source
`setsockopt` values:
-
SOL_SOCKET - specifies the protocol layer the option applies to.
SOL_SOCKET is basic socket options (as opposed to something like IPPROTO_TCP for TCP socket options).
-
SO_REUSEADDR - indicates that the rules used in validating addresses
supplied in a bind(2) call should allow reuse of local addresses. This will allow us to re-bind to a port if we were shutdown and started right away. This will still throw an "address in use" if a socket is active on the port.
# File lib/dat-tcp.rb, line 211 def self.configure(tcp_server) tcp_server.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true) tcp_server end
for_fd(file_descriptor)
click to toggle source
# File lib/dat-tcp.rb, line 197 def self.for_fd(file_descriptor) configure(::TCPServer.for_fd(file_descriptor)) end
new(ip, port)
click to toggle source
# File lib/dat-tcp.rb, line 193 def self.new(ip, port) configure(::TCPServer.new(ip, port)) end