Module: Bones::RPC::Connection::Socket::Connectable
Overview
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
- #host ⇒ Object readonly
- #port ⇒ Object readonly
Class Method Summary collapse
-
.included(klass) ⇒ Object
Bring in the class methods when included.
Instance Method Summary collapse
-
#alive? ⇒ true, false
Is the socket connection alive?.
-
#read(size = nil, buf = nil) ⇒ Object
Read from the TCP socket.
-
#readpartial(maxlen, buf = nil) ⇒ Object
Read from the TCP socket.
-
#set_encoding(string) ⇒ Object
Set the encoding of the underlying socket.
-
#write(*args) ⇒ Integer
Write to the socket.
Instance Attribute Details
#host ⇒ Object (readonly)
8 9 10 |
# File 'lib/bones/rpc/connection/socket/connectable.rb', line 8 def host @host end |
#port ⇒ Object (readonly)
8 9 10 |
# File 'lib/bones/rpc/connection/socket/connectable.rb', line 8 def port @port end |
Class Method Details
.included(klass) ⇒ Object
Bring in the class methods when included.
37 38 39 |
# File 'lib/bones/rpc/connection/socket/connectable.rb', line 37 def self.included(klass) klass.send(:extend, ClassMethods) end |
Instance Method Details
#alive? ⇒ true, false
Is the socket connection alive?
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/bones/rpc/connection/socket/connectable.rb', line 18 def alive? io = to_io if Kernel::select([ io ], nil, [ io ], 0) !eof? rescue false else true end rescue IOError false end |
#read(size = nil, buf = nil) ⇒ Object
Read from the TCP socket.
49 50 51 52 |
# File 'lib/bones/rpc/connection/socket/connectable.rb', line 49 def read(size = nil, buf = nil) check_if_alive! handle_socket_errors { super } end |
#readpartial(maxlen, buf = nil) ⇒ Object
Read from the TCP socket.
62 63 64 65 |
# File 'lib/bones/rpc/connection/socket/connectable.rb', line 62 def readpartial(maxlen, buf = nil) check_if_alive! handle_socket_errors { super } end |
#set_encoding(string) ⇒ Object
Set the encoding of the underlying socket.
72 73 74 |
# File 'lib/bones/rpc/connection/socket/connectable.rb', line 72 def set_encoding(string) to_io.set_encoding(string) end |
#write(*args) ⇒ Integer
Write to the socket.
86 87 88 89 |
# File 'lib/bones/rpc/connection/socket/connectable.rb', line 86 def write(*args) check_if_alive! handle_socket_errors { super } end |