Class: Celluloid::ZMQ::Socket
- Inherits:
-
Object
- Object
- Celluloid::ZMQ::Socket
- Defined in:
- lib/celluloid/zmq/sockets.rb
Direct Known Subclasses
DealerSocket, PubSocket, PullSocket, PushSocket, RepSocket, ReqSocket, RouterSocket, SubSocket
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.
9 10 11 |
# File 'lib/celluloid/zmq/sockets.rb', line 9 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/
54 55 56 57 58 |
# File 'lib/celluloid/zmq/sockets.rb', line 54 def bind(addr) unless ::ZMQ::Util.resultcode_ok? @socket.bind(addr) raise IOError, "couldn't bind to #{addr}: #{::ZMQ::Util.error_string}" end end |
#close ⇒ Object
Close the socket
61 62 63 |
# File 'lib/celluloid/zmq/sockets.rb', line 61 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/
13 14 15 16 17 18 |
# File 'lib/celluloid/zmq/sockets.rb', line 13 def connect(addr) unless ::ZMQ::Util.resultcode_ok? @socket.connect addr raise IOError, "error connecting to #{addr}: #{::ZMQ::Util.error_string}" end true end |
#get(option) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/celluloid/zmq/sockets.rb', line 42 def get(option) option_value = [] unless ::ZMQ::Util.resultcode_ok? @socket.getsockopt(option, option_value) raise IOError, "couldn't get value for option #{option}: #{::ZMQ::Util.error_string}" end option_value[0] end |
#identity ⇒ Object
32 33 34 |
# File 'lib/celluloid/zmq/sockets.rb', line 32 def identity @socket.identity end |
#identity=(value) ⇒ Object
28 29 30 |
# File 'lib/celluloid/zmq/sockets.rb', line 28 def identity=(value) @socket.identity = value end |
#set(option, value, length = nil) ⇒ Object
36 37 38 39 40 |
# File 'lib/celluloid/zmq/sockets.rb', line 36 def set(option, value, length = nil) unless ::ZMQ::Util.resultcode_ok? @socket.setsockopt(option, value, length) raise IOError, "couldn't set value for option #{option}: #{::ZMQ::Util.error_string}" end end |