Class DRb::DRbUNIXSocket
In: drb/unix.rb
Parent: DRbTCPSocket

Methods

accept   close   new   open   open_server   parse_uri   set_sockopt   uri_option  

Constants

Max_try = 10   import from tempfile.rb

Public Class methods

[Source]

# File drb/unix.rb, line 56
    def initialize(uri, soc, config={}, server_mode = false)
      super(uri, soc, config)
      set_sockopt(@socket)
      @server_mode = server_mode
      @acl = nil
    end

[Source]

# File drb/unix.rb, line 21
    def self.open(uri, config)
      filename, option = parse_uri(uri)
      filename.untaint
      soc = UNIXSocket.open(filename)
      self.new(uri, soc, config)
    end

[Source]

# File drb/unix.rb, line 28
    def self.open_server(uri, config)
      filename, option = parse_uri(uri)
      if filename.size == 0
        soc = temp_server
        filename = soc.path
        uri = 'drbunix:' + soc.path
      else
        soc = UNIXServer.open(filename)
      end
      owner = config[:UNIXFileOwner]
      group = config[:UNIXFileGroup]
      if owner || group
        require 'etc'
        owner = Etc.getpwnam( owner ).uid  if owner
        group = Etc.getgrnam( group ).gid  if group
        File.chown owner, group, filename
      end
      mode = config[:UNIXFileMode]
      File.chmod(mode, filename) if mode

      self.new(uri, soc, config, true)
    end

[Source]

# File drb/unix.rb, line 10
    def self.parse_uri(uri)
      if /^drbunix:(.*?)(\?(.*))?$/ =~ uri 
        filename = $1
        option = $3
        [filename, option]
      else
        raise(DRbBadScheme, uri) unless uri =~ /^drbunix:/
        raise(DRbBadURI, 'can\'t parse uri:' + uri)
      end
    end

[Source]

# File drb/unix.rb, line 51
    def self.uri_option(uri, config)
      filename, option = parse_uri(uri)
      return "drbunix:#{filename}", option
    end

Public Instance methods

[Source]

# File drb/unix.rb, line 97
    def accept
      s = @socket.accept
      self.class.new(nil, s, @config)
    end

[Source]

# File drb/unix.rb, line 89
    def close
      return unless @socket
      path = @socket.path if @server_mode
      @socket.close
      File.unlink(path) if @server_mode
      @socket = nil
    end

[Source]

# File drb/unix.rb, line 102
    def set_sockopt(soc)
      soc.fcntl(Fcntl::F_SETFL, Fcntl::FD_CLOEXEC) if defined? Fcntl::FD_CLOEXEC
    end

[Validate]

ruby-doc.org is hosted and maintained by James Britt and Happy Camper Studios, a Ruby application development company in Phoenix, Arizona. The site was created in 2002 as part of the Ruby Documentation Project to promote the Ruby language and to help other Ruby hackers.

Documentation content on ruby-doc.org is provided by remarkable members of the Ruby community.

For more information on the Ruby programming language, visit ruby-lang.org.

Want to help improve Ruby's API docs? See Ruby Documentation Guidelines.