Module: EventMachine::Syslog::ConnectionUDP::UNIX

Includes:
EventMachine::Syslog::ConnectionUDP
Defined in:
lib/em-syslog/connection_unix.rb

Overview

Our module to pass to EventMachine to handle the UDP Connection over IPC Socket

Class Method Summary collapse

Instance Method Summary collapse

Methods included from EventMachine::Syslog::ConnectionUDP

#notify_readable, #read_packet

Class Method Details

.create_unixObject

we also have to code around the difference of Socket.new in ruby 1.8 and 1.9



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/em-syslog/connection_unix.rb', line 13

def self.create_unix
  case RUBY_VERSION.split('.')[1].to_i
  when 8
    ::Socket.new(
      ::Socket::PF_UNIX,
      ::Socket::SOCK_DGRAM,
      0
    )
  else
    ::Socket.new(
      ::Socket::PF_UNIX,
      ::Socket::SOCK_DGRAM
    )
  end
end

Instance Method Details

#send_msg(msg) ⇒ Object



35
36
37
# File 'lib/em-syslog/connection_unix.rb', line 35

def send_msg( msg)
  @unix_connection.send( msg, 0)
end

#setup(ipc, path) ⇒ Object



29
30
31
32
33
# File 'lib/em-syslog/connection_unix.rb', line 29

def setup( ipc, path)
  ipc_address = ::Socket.pack_sockaddr_un( path)
  @unix_connection = ipc
  @unix_connection.connect( ipc_address)
end