Class: CarbonMU::ReadSocket
- Inherits:
-
CarbonIPCSocket
- Object
- CarbonIPCSocket
- CarbonMU::ReadSocket
- Defined in:
- lib/carbonmu/ipc/read_socket.rb
Instance Attribute Summary
Attributes inherited from CarbonIPCSocket
Instance Method Summary collapse
-
#initialize(port = '*') ⇒ ReadSocket
constructor
A new instance of ReadSocket.
- #port_number ⇒ Object
- #read ⇒ Object
Methods inherited from CarbonIPCSocket
Constructor Details
#initialize(port = '*') ⇒ ReadSocket
Returns a new instance of ReadSocket.
6 7 8 9 |
# File 'lib/carbonmu/ipc/read_socket.rb', line 6 def initialize(port = '*') @zmq_socket = Celluloid::ZMQ::PullSocket.new @zmq_socket.bind("tcp://127.0.0.1:#{port}") end |
Instance Method Details
#port_number ⇒ Object
15 16 17 18 19 |
# File 'lib/carbonmu/ipc/read_socket.rb', line 15 def port_number raw_endpoint = @zmq_socket.get(::ZMQ::LAST_ENDPOINT) || nil return nil if raw_endpoint.nil? raw_endpoint.match(/\:(\d+)/)[1].to_i end |
#read ⇒ Object
11 12 13 |
# File 'lib/carbonmu/ipc/read_socket.rb', line 11 def read @zmq_socket.read end |