Class: Fyrehose::UDPClient

Inherits:
AbstractClient show all
Defined in:
lib/fyrehose/udp_client.rb

Constant Summary

Constants inherited from AbstractClient

AbstractClient::TIMEOUT

Instance Method Summary collapse

Methods inherited from AbstractClient

#deliver, #initialize

Constructor Details

This class inherits a constructor from Fyrehose::AbstractClient

Instance Method Details

#open_connectionObject



3
4
5
6
# File 'lib/fyrehose/udp_client.rb', line 3

def open_connection
  @sock = UDPSocket.new
  @sock.connect(@host, @port)
end

#send_data(data) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/fyrehose/udp_client.rb', line 8

def send_data(data)
  Timeout::timeout(@timeout) do
    open_connection unless @sock
    @sock.send(data, 0); 0
  end
rescue Exception => e
  @sock = nil
  raise e
end