Module: Celluloid::ZMQ::Socket::Readable
- Extended by:
- Forwardable
- Defined in:
- lib/celluloid/zmq/socket/readable.rb
Overview
Readable 0MQ sockets have a read method
Instance Method Summary collapse
-
#bind(addr) ⇒ Object
always set LINGER on readable sockets.
- #connect(addr) ⇒ Object
-
#read(buffer = "") ⇒ Object
Read a message from the socket.
-
#read_multipart(buffer = []) ⇒ Object
Reads a multipart message, stores it into the given buffer and returns the buffer.
Instance Method Details
#bind(addr) ⇒ Object
always set LINGER on readable sockets
10 11 12 13 |
# File 'lib/celluloid/zmq/socket/readable.rb', line 10 def bind(addr) self.linger = @linger super(addr) end |
#connect(addr) ⇒ Object
15 16 17 18 |
# File 'lib/celluloid/zmq/socket/readable.rb', line 15 def connect(addr) self.linger = @linger super(addr) end |
#read(buffer = "") ⇒ Object
Read a message from the socket
21 22 23 24 25 26 27 28 |
# File 'lib/celluloid/zmq/socket/readable.rb', line 21 def read(buffer = "") ZMQ.wait_readable(@socket) if ZMQ.evented? unless result_ok? @socket.recv_string buffer fail IOError, "error receiving ZMQ string: #{::ZMQ::Util.error_string}" end buffer end |
#read_multipart(buffer = []) ⇒ Object
Reads a multipart message, stores it into the given buffer and returns the buffer.
35 36 37 38 39 40 41 42 |
# File 'lib/celluloid/zmq/socket/readable.rb', line 35 def read_multipart(buffer = []) ZMQ.wait_readable(@socket) if ZMQ.evented? unless result_ok? @socket.recv_strings buffer fail IOError, "error receiving ZMQ string: #{::ZMQ::Util.error_string}" end buffer end |