Class: Celluloid::ZMQ::Socket
- Inherits:
-
Object
- Object
- Celluloid::ZMQ::Socket
- Extended by:
- Forwardable
- Defined in:
- lib/celluloid/zmq/socket.rb,
lib/celluloid/zmq/socket/types.rb,
lib/celluloid/zmq/socket/readable.rb,
lib/celluloid/zmq/socket/writable.rb
Defined Under Namespace
Modules: Readable, Writable Classes: Dealer, Pub, Pull, Push, Rep, Req, Router, Sub, XPub
Instance Attribute Summary collapse
-
#linger ⇒ Object
Returns the value of attribute linger.
Instance Method Summary collapse
-
#bind(addr) ⇒ Object
Bind to the given 0MQ address Address should be in the form: tcp://1.2.3.4:5678/.
-
#close ⇒ Object
Close the socket.
-
#connect(addr) ⇒ Object
Connect to the given 0MQ address Address should be in the form: tcp://1.2.3.4:5678/.
- #get(option) ⇒ Object
- #identity ⇒ Object
- #identity=(value) ⇒ Object
-
#initialize(type) ⇒ Socket
constructor
Create a new socket.
- #set(option, value, length = nil) ⇒ Object
Constructor Details
Instance Attribute Details
#linger ⇒ Object
Returns the value of attribute linger.
11 12 13 |
# File 'lib/celluloid/zmq/socket.rb', line 11 def linger @linger end |
Instance Method Details
#bind(addr) ⇒ Object
Bind to the given 0MQ address Address should be in the form: tcp://1.2.3.4:5678/
60 61 62 63 64 |
# File 'lib/celluloid/zmq/socket.rb', line 60 def bind(addr) unless result_ok? @socket.bind(addr) fail IOError, "couldn't bind to #{addr}: #{::ZMQ::Util.error_string}" end end |
#close ⇒ Object
Close the socket
67 68 69 |
# File 'lib/celluloid/zmq/socket.rb', line 67 def close @socket.close end |
#connect(addr) ⇒ Object
Connect to the given 0MQ address Address should be in the form: tcp://1.2.3.4:5678/
15 16 17 18 19 20 |
# File 'lib/celluloid/zmq/socket.rb', line 15 def connect(addr) unless result_ok? @socket.connect addr fail IOError, "error connecting to #{addr}: #{::ZMQ::Util.error_string}" end true end |
#get(option) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/celluloid/zmq/socket.rb', line 48 def get(option) option_value = [] unless result_ok? @socket.getsockopt(option, option_value) fail IOError, "couldn't get value for option #{option}: #{::ZMQ::Util.error_string}" end option_value[0] end |
#identity ⇒ Object
37 38 39 40 |
# File 'lib/celluloid/zmq/socket.rb', line 37 def identity # de @socket.identity get(::ZMQ::IDENTITY) end |
#identity=(value) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/celluloid/zmq/socket.rb', line 30 def identity=(value) unless result_ok? @socket.setsockopt(::ZMQ::IDENTITY, "#{value}") fail IOError, "couldn't set identity: #{::ZMQ::Util.error_string}" end # de @socket.identity = value end |
#set(option, value, length = nil) ⇒ Object
42 43 44 45 46 |
# File 'lib/celluloid/zmq/socket.rb', line 42 def set(option, value, length = nil) unless result_ok? @socket.setsockopt(option, value, length) fail IOError, "couldn't set value for option #{option}: #{::ZMQ::Util.error_string}" end end |