lib/ionian/extension/socket.rb in ionian-0.6.6 vs lib/ionian/extension/socket.rb in ionian-0.6.7

- old
+ new

@@ -52,13 +52,19 @@ end # For connection-oriented protocols, prevent #close from returning # immediately and try to deliver any data in the send buffer if value # is true. + # + # Args: + # Time: Time in seconds to remain open before discarding data and + # sending a RST packet. # ( SO_LINGER ) - def linger= value - param = value ? 1 : 0 - self.setsockopt ::Socket::SOL_SOCKET, ::Socket::SO_LINGER, [param].pack('i') + def linger= enable, time: 60 + # TODO: Passing a kwarg doesn't work here because of the + # assignment operator. Causes parser error. + param = enable ? 1 : 0 + self.setsockopt ::Socket::SOL_SOCKET, ::Socket::SO_LINGER, [param, time.to_i].pack('ii') end alias_method :linger?, :linger # Returns true if local address reuse is allowed. \ No newline at end of file