class XenStore::Transport::UnixSocketTransport
A Transport
implementation which communicates with XenStore
over a UNIX socket.
Public Class Methods
new(path = nil)
click to toggle source
# File lib/xsrb/transport.rb, line 44 def initialize(path = nil) path ||= XenStore::Utils.unix_socket_path @sock = UNIXSocket.new path # Ensure the socket is closed when this object is garbage collected ObjectSpace.define_finalizer(self, proc { @sock.close }) end
Public Instance Methods
close()
click to toggle source
# File lib/xsrb/transport.rb, line 65 def close @sock.close end
recv(size)
click to toggle source
# File lib/xsrb/transport.rb, line 56 def recv(size) chunks = [] while size chunks << @sock.read(size) size -= chunks[-1].length end chunks.join '' end
send(data)
click to toggle source
# File lib/xsrb/transport.rb, line 52 def send(data) @sock.write(data) end