Class: Bundesstrasse::Socket
- Inherits:
-
Object
- Object
- Bundesstrasse::Socket
- Includes:
- Errors
- Defined in:
- lib/bundesstrasse/socket.rb
Direct Known Subclasses
Instance Method Summary collapse
- #bind(address) ⇒ Object
- #close! ⇒ Object
- #connect(address) ⇒ Object
- #connected? ⇒ Boolean
-
#initialize(socket, options = {}) ⇒ Socket
constructor
A new instance of Socket.
- #more_parts? ⇒ Boolean
- #pointer ⇒ Object (also: #socket)
- #read(buffer = '') ⇒ Object
- #read_multipart ⇒ Object
- #read_nonblocking(buffer = '') ⇒ Object
- #write(message) ⇒ Object
- #write_multipart(*parts) ⇒ Object
- #write_nonblocking(message) ⇒ Object
Methods included from Errors
Constructor Details
#initialize(socket, options = {}) ⇒ Socket
Returns a new instance of Socket.
5 6 7 8 |
# File 'lib/bundesstrasse/socket.rb', line 5 def initialize(socket, ={}) @socket = socket setup!() end |
Instance Method Details
#bind(address) ⇒ Object
10 11 12 |
# File 'lib/bundesstrasse/socket.rb', line 10 def bind(address) @connected = error_check { @socket.bind(address) } end |
#close! ⇒ Object
18 19 20 |
# File 'lib/bundesstrasse/socket.rb', line 18 def close! !(@connected = !error_check { @socket.close }) end |
#connect(address) ⇒ Object
14 15 16 |
# File 'lib/bundesstrasse/socket.rb', line 14 def connect(address) @connected = error_check { @socket.connect(address) } end |
#connected? ⇒ Boolean
59 60 61 |
# File 'lib/bundesstrasse/socket.rb', line 59 def connected? @connected end |
#more_parts? ⇒ Boolean
50 51 52 |
# File 'lib/bundesstrasse/socket.rb', line 50 def more_parts? @socket.more_parts? end |
#pointer ⇒ Object Also known as: socket
54 55 56 |
# File 'lib/bundesstrasse/socket.rb', line 54 def pointer @socket.socket end |
#read(buffer = '') ⇒ Object
22 23 24 25 |
# File 'lib/bundesstrasse/socket.rb', line 22 def read(buffer='') connected_error_check { @socket.recv_string buffer } buffer end |
#read_multipart ⇒ Object
40 41 42 43 44 |
# File 'lib/bundesstrasse/socket.rb', line 40 def read_multipart = [] connected_error_check { @socket.recv_strings() } end |
#read_nonblocking(buffer = '') ⇒ Object
31 32 33 34 |
# File 'lib/bundesstrasse/socket.rb', line 31 def read_nonblocking(buffer='') connected_error_check { @socket.recv_string(buffer, ZMQ::NonBlocking) } buffer end |
#write(message) ⇒ Object
27 28 29 |
# File 'lib/bundesstrasse/socket.rb', line 27 def write() connected_error_check { @socket.send_string() } end |
#write_multipart(*parts) ⇒ Object
46 47 48 |
# File 'lib/bundesstrasse/socket.rb', line 46 def write_multipart(*parts) connected_error_check { @socket.send_strings(parts) } end |
#write_nonblocking(message) ⇒ Object
36 37 38 |
# File 'lib/bundesstrasse/socket.rb', line 36 def write_nonblocking() connected_error_check { @socket.send_string(, ZMQ::NonBlocking) } end |