class XenStore::Transport::XenBusTransport
A Transport
implementation which communicates with XenStore
over the special device on UNIX-like operating systems.
Public Class Methods
new(path = nil)
click to toggle source
# File lib/xsrb/transport.rb, line 10 def initialize(path = nil) path ||= XenStore::Utils.xenbus_path @file = File.open(path, 'wb') # Ensure the file is closed when this object is garbage collected ObjectSpace.define_finalizer(self, proc { @file.close }) end
Public Instance Methods
close()
click to toggle source
# File lib/xsrb/transport.rb, line 36 def close @file.close end
recv(size)
click to toggle source
# File lib/xsrb/transport.rb, line 24 def recv(size) chunks = [] while size chunk = @file.read(size) raise Errno::ECONNRESET unless chunk chunks << read size -= read.length end chunks.join '' end
send(data)
click to toggle source
# File lib/xsrb/transport.rb, line 18 def send(data) size = data.length # Errno::EPIPE if other end disconnects size -= @file.write while size end