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)
-
- (Object) linger
Returns the value of attribute linger.
Instance Method Summary (collapse)
-
- (Object) bind(addr)
Bind to the given 0MQ address Address should be in the form: tcp://1.2.3.4:5678/.
-
- (Object) close
Close the socket.
-
- (Object) connect(addr)
Connect to the given 0MQ address Address should be in the form: tcp://1.2.3.4:5678/.
- - (Object) identity
- - (Object) identity=(value)
-
- (Socket) initialize(type)
constructor
Create a new socket.
Constructor Details
- (Socket) initialize(type)
Create a new socket
5 6 7 8 |
# File 'lib/celluloid/zmq/sockets.rb', line 5 def initialize(type) @socket = Celluloid::ZMQ.context.socket ::ZMQ.const_get(type.to_s.upcase) @linger = 0 end |
Instance Attribute Details
- (Object) linger
Returns the value of attribute linger
9 10 11 |
# File 'lib/celluloid/zmq/sockets.rb', line 9 def linger @linger end |
Instance Method Details
- (Object) bind(addr)
Bind to the given 0MQ address Address should be in the form: tcp://1.2.3.4:5678/
38 39 40 41 42 |
# File 'lib/celluloid/zmq/sockets.rb', line 38 def bind(addr) unless ::ZMQ::Util.resultcode_ok? @socket.bind(addr) raise IOError, "couldn't bind to #{addr}: #{::ZMQ::Util.error_string}" end end |
- (Object) close
Close the socket
45 46 47 |
# File 'lib/celluloid/zmq/sockets.rb', line 45 def close @socket.close end |
- (Object) connect(addr)
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 |
- (Object) identity
32 33 34 |
# File 'lib/celluloid/zmq/sockets.rb', line 32 def identity @socket.identity end |
- (Object) identity=(value)
28 29 30 |
# File 'lib/celluloid/zmq/sockets.rb', line 28 def identity=(value) @socket.identity = value end |