Class: Sanford::Protocol::Socket
- Inherits:
-
Struct
- Object
- Struct
- Sanford::Protocol::Socket
- Defined in:
- lib/sanford-protocol/connection.rb
Instance Attribute Summary collapse
-
#tcp_socket ⇒ Object
Returns the value of attribute tcp_socket.
Instance Method Summary collapse
- #close ⇒ Object
- #close_write ⇒ Object
- #decode(handler, num_bytes) ⇒ Object
- #encode(handler, data) ⇒ Object
- #peek(number_of_bytes = 1) ⇒ Object
- #read(number_of_bytes) ⇒ Object
- #write(*binary_strings) ⇒ Object
Instance Attribute Details
#tcp_socket ⇒ Object
Returns the value of attribute tcp_socket
61 62 63 |
# File 'lib/sanford-protocol/connection.rb', line 61 def tcp_socket @tcp_socket end |
Instance Method Details
#close ⇒ Object
82 83 84 |
# File 'lib/sanford-protocol/connection.rb', line 82 def close tcp_socket.close rescue false end |
#close_write ⇒ Object
86 87 88 |
# File 'lib/sanford-protocol/connection.rb', line 86 def close_write tcp_socket.close_write rescue false end |
#decode(handler, num_bytes) ⇒ Object
62 63 64 |
# File 'lib/sanford-protocol/connection.rb', line 62 def decode(handler, num_bytes) handler.decode(read(num_bytes)) end |
#encode(handler, data) ⇒ Object
66 67 68 |
# File 'lib/sanford-protocol/connection.rb', line 66 def encode(handler, data) handler.encode data end |
#peek(number_of_bytes = 1) ⇒ Object
78 79 80 |
# File 'lib/sanford-protocol/connection.rb', line 78 def peek(number_of_bytes = 1) recv(number_of_bytes, ::Socket::MSG_PEEK) end |
#read(number_of_bytes) ⇒ Object
70 71 72 |
# File 'lib/sanford-protocol/connection.rb', line 70 def read(number_of_bytes) recv(number_of_bytes) end |
#write(*binary_strings) ⇒ Object
74 75 76 |
# File 'lib/sanford-protocol/connection.rb', line 74 def write(*binary_strings) tcp_socket.send(binary_strings.join, 0) end |