Class: BasicSocket
Instance Method Summary collapse
-
#read_object ⇒ Object
it should be noted that in order to use read_object and write_object, the object versions on the client and server side must be identical.
- #read_with_amount_header ⇒ Object
- #write_object(obj) ⇒ Object
- #write_with_amount_header(message) ⇒ Object
Instance Method Details
#read_object ⇒ Object
it should be noted that in order to use read_object and write_object, the object versions on the client and server side must be identical
17 18 19 |
# File 'lib/doh/core/socket.rb', line 17 def read_object Marshal.load(read_with_amount_header) end |
#read_with_amount_header ⇒ Object
4 5 6 7 |
# File 'lib/doh/core/socket.rb', line 4 def read_with_amount_header lenstr = self.read(8) self.read(lenstr.to_i) end |
#write_object(obj) ⇒ Object
21 22 23 |
# File 'lib/doh/core/socket.rb', line 21 def write_object(obj) write_with_amount_header(Marshal.dump(obj)) end |
#write_with_amount_header(message) ⇒ Object
9 10 11 12 13 |
# File 'lib/doh/core/socket.rb', line 9 def write_with_amount_header() lenstr = .size.to_s.ljust(8) self.write(lenstr) self.write() end |