Sha256: 01362306c33f49ddc611935d8042c9ddcc5942083be6d53e98a56ea4f721a21c
Contents?: true
Size: 797 Bytes
Versions: 1
Compression:
Stored size: 797 Bytes
Contents
require 'socket' require 'sanford-protocol' module AndSon class Connection < Struct.new(:host, :port) module NoRequest def self.to_s; "[?]"; end end def open protocol_connection = Sanford::Protocol::Connection.new(tcp_socket) yield protocol_connection if block_given? ensure protocol_connection.close end private # 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 http://linux.die.net/man/7/tcp def tcp_socket TCPSocket.new(host, port).tap do |socket| socket.setsockopt(::Socket::IPPROTO_TCP, ::Socket::TCP_NODELAY, true) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
and-son-0.1.1 | lib/and-son/connection.rb |