Class: Blondy::DHCPD::Server

Inherits:
EM::Connection
  • Object
show all
Defined in:
lib/blondy/dhcpd/server.rb

Overview

Main class for handling connections

Instance Method Summary collapse

Constructor Details

#initializeServer

Returns a new instance of Server.



11
12
13
14
# File 'lib/blondy/dhcpd/server.rb', line 11

def initialize
	@buffer = String.new
	super
end

Instance Method Details

#receive_data(data) ⇒ Object

Fires up Dispatcher and send reply back by callback



16
17
18
19
20
21
22
23
24
# File 'lib/blondy/dhcpd/server.rb', line 16

def receive_data(data)
	@buffer.clear if (@buffer.size + data.size) > 1000
	@buffer += data

	if @buffer.unpack('C4Nn2N4C16C192NC*').include?($DHCP_MAGIC)
	  process_message(@buffer.dup)
	  @buffer.clear
	end
end