Module: SimpleRPC::SocketProtocol::Stream
- Defined in:
- lib/simplerpc/socket_protocol.rb
Overview
Send objects by streaming them through a socket using a serialiser such as Marshal.
Fast and with low memory requirements, but is inherently unsafe (arbitrary code execution) and doesn’t work with some serialisers.
SimpleRPC uses this library for calls, and uses SocketProtocol::Simple for auth challenges (since it is safer)
Class Method Summary collapse
-
.recv(s, serialiser, timeout = nil) ⇒ Object
Recieve using a serialiser reading from the socket.
-
.send(s, obj, serialiser, timeout = nil) ⇒ Object
Send using a serialiser writing through the socket.
Class Method Details
.recv(s, serialiser, timeout = nil) ⇒ Object
Recieve using a serialiser reading from the socket
47 48 49 50 |
# File 'lib/simplerpc/socket_protocol.rb', line 47 def self.recv(s, serialiser, timeout = nil) raise Errno::ETIMEDOUT unless IO.select([s], [], [], timeout) return serialiser.load(s) end |
.send(s, obj, serialiser, timeout = nil) ⇒ Object
Send using a serialiser writing through the socket
41 42 43 44 |
# File 'lib/simplerpc/socket_protocol.rb', line 41 def self.send(s, obj, serialiser, timeout = nil) raise Errno::ETIMEDOUT unless IO.select([], [s], [], timeout) return serialiser.dump(obj, s) end |