The Connector class handles outgoing connections
#handle_close is called when a close event occurs for this Connector.
# File lib/network/connector.rb, line 60 def handle_close @sock.close rescue Exception log.error "Connector#handle_close" log.error $! end
init is called before using the Connector
returns
true is acceptor is properly initialized
# File lib/network/connector.rb, line 37 def init # Open a socket for the server to connect on. @sock = TCPSocket.new(@address , @server.port) @sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true) @sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER, false) unless RUBY_PLATFORM =~ %rwin32/ @sock.fcntl(Fcntl::F_SETFL, Fcntl::O_NONBLOCK) end c = Connection.new(@server, @sock) if c.init log.info "(#{c.object_id}) Connection made." publish(c) true else false end rescue Exception log.error "Connector#init" log.error $! false end