class AndSon::Connection
Public Instance Methods
open() { |protocol_connection| ... }
click to toggle source
# File lib/and-son/connection.rb, line 11 def open protocol_connection = Sanford::Protocol::Connection.new(tcp_socket) yield protocol_connection if block_given? ensure protocol_connection.close if protocol_connection end
Private Instance Methods
tcp_socket()
click to toggle source
TCP_NODELAY is set to disable buffering. In the case of Sanford communication, we have all the information we need to send up front and are closing the connection, so it doesn't need to buffer. See linux.die.net/man/7/tcp
# File lib/and-son/connection.rb, line 25 def tcp_socket TCPSocket.new(host, port).tap do |socket| socket.setsockopt(::Socket::IPPROTO_TCP, ::Socket::TCP_NODELAY, true) end end