module Ionian::Extension::Socket

A mixin for Socket objects.

This module was designed to be extended by instantiated objects that implement the standard library Socket class. my_socket.extend Ionian::Socket

Extending this module also extends Ionian::IO.

Public Class Methods

extended(obj) click to toggle source

Called automaticallly when the object is extended with extend.

# File lib/ionian/extension/socket.rb, line 16
def self.extended(obj)
  obj.extend Ionian::Extension::IO
  obj.initialize_ionian_socket
end

Public Instance Methods

initialize_ionian_socket() click to toggle source

Initialize the Ionian Socket variables. This is called automatically if extend is called on an object.

# File lib/ionian/extension/socket.rb, line 23
def initialize_ionian_socket
end
no_delay() click to toggle source

Returns true if the TCP_NODELAY flag is enabled (Nagle disabled). Otherwise false.

# File lib/ionian/extension/socket.rb, line 28
def no_delay
  nagle_disabled = self.getsockopt(::Socket::IPPROTO_TCP, ::Socket::TCP_NODELAY).data.ord
  nagle_disabled > 0 ? true : false
end
no_delay=(value) click to toggle source

Setting to true enables the TCP_NODELAY flag (disables Nagle). Setting to false disables the flag (enables Nagle).

# File lib/ionian/extension/socket.rb, line 35
def no_delay=(value)
  disable_nagle = value ? 1 : 0
  self.setsockopt ::Socket::IPPROTO_TCP, ::Socket::TCP_NODELAY, disable_nagle
end