class Glima::IMAP

IMAP client with IMAP extentions provided by Gmail

https://developers.google.com/gmail/imap/imap-extensions

Public Class Methods

new(host, port_or_options = {}, usessl = false, certs = nil, verify = true) click to toggle source
Calls superclass method
# File lib/glima/imap.rb, line 11
def initialize(host, port_or_options = {},
               usessl = false, certs = nil, verify = true)
  super
  @parser = Glima::IMAP::ResponseParser.new

  set_keepalive(@sock, 30) # set *TCP* Keepalive
end

Public Instance Methods

set_keepalive(sock, sec) click to toggle source

www.winehq.org/pipermail/wine-devel/2015-July/108583.html TCP_KEEPALIVE on Darwin corresponds to Linux TCP_KEEPIDLE, not TCP_KEEPINTVL.

  • Darwin (macOS) /usr/include/netinet/tcp.h:

    : #define TCP_KEEPALIVE  0x10    /* idle time used when SO_KEEPALIVE is enabled */
: TCP_KEEPALIVE = 0x10
: TCP_KEEPCNT   = 0x102
: TCP_KEEPINTVL = 0x101
  • Linux

: TCP_KEEPIDLE
: TCP_KEEPCNT
: TCP_KEEPINTVL

Configurable TCP keepalives by normelton: PR #262 redis/redis-rb

https://github.com/redis/redis-rb/pull/262
# File lib/glima/imap.rb, line 36
def set_keepalive(sock, sec)
  xTCP_KEEPIDLE = if RUBY_PLATFORM =~ /darwin/ then 0x10 else :TCP_KEEPIDLE end

  idle, interval, probes = if sec >= 60
                             [sec - 20, 10, 2]
                           elsif sec >= 30
                             [sec - 10,  5, 2]
                           elsif sec >= 5
                             [sec -  2,  2, 1]
                           end

  sock.setsockopt(:SOL_SOCKET,  :SO_KEEPALIVE,  true)
  sock.setsockopt(:IPPROTO_TCP, xTCP_KEEPIDLE,  idle)
  sock.setsockopt(:IPPROTO_TCP, :TCP_KEEPINTVL, interval)
  sock.setsockopt(:IPPROTO_TCP, :TCP_KEEPCNT,   probes)
end