Class: DRb::DRbUNIXSocket

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

new(uri, soc, config={}, server_mode = false)

[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

open(uri, config)

[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

open_server(uri, config)

[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

parse_uri(uri)

[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

uri_option(uri, config)

[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

accept()

[Source]

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

close()

[Source]

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

set_sockopt(soc)

[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]