Sha256: 0d83a84fd2c47ce59ca0cdb6bf6fac6a23862f85772a00df19153922b4c9605d

Contents?: true

Size: 713 Bytes

Versions: 1

Compression:

Stored size: 713 Bytes

Contents

module NFS
  class Server
    attr_reader :dir, :host, :port, :protocol

    def initialize(dir:, host:, port:, protocol:)
      @dir = dir
      @host = host
      @port = port
      @protocol = protocol

      @handler = Handler.new(FileProxy.new(dir))
      @server = server_class.new(@handler.programs, port, host)
    end

    def join
      @server.join
    end

    def start
      @server.start
    end

    def shutdown
      @server.shutdown
    end

    private

    def server_class
      if protocol == :tcp
        SUNRPC::TCPServer
      elsif protocol == :udp
        SUNRPC::UDPServer
      else
        raise "Unsupported protocol #{protocol}, expected :tcp or :udp"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nfs-rb-1.0.2 lib/nfs/server.rb