Class: DRb::DRbUNIXSocket
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
| Class Chain: 
          self,
           DRbTCPSocket | |
| Instance Chain: 
          self,
           DRbTCPSocket | |
| Inherits: | DRb::DRbTCPSocket 
 | 
| Defined in: | lib/drb/unix.rb | 
Overview
Implements DRb over a UNIX socket
::DRb UNIX socket URIs look like drbunix:<path>?<option>.  The option is optional.
Constant Summary
- 
    Max_try =
    # File 'lib/drb/unix.rb', line 70import from tempfile.rb 10
Class Method Summary
- .new(uri, soc, config = {}, server_mode = false) ⇒ DRbUNIXSocket constructor
- .open(uri, config)
- .open_server(uri, config)
- .parse_uri(uri)
- .uri_option(uri, config)
- .temp_server private
DRbTCPSocket - Inherited
| .getservername | Returns the hostname of this server. | 
| .new | Create a new  | 
| .open | |
| .open_server | |
| .open_server_inaddr_any | For the families available for  | 
| .uri_option | Parse uri into a [uri, option] pair. | 
| .parse_uri | |
Instance Attribute Summary
DRbTCPSocket - Inherited
Instance Method Summary
DRbTCPSocket - Inherited
| #accept | On the server side, for an instance returned by  | 
| #close | Close the connection. | 
| #peeraddr | Get the address of our TCP peer (the other end of the socket we are bound to. | 
| #recv_reply | On the client side, receive a reply from the server. | 
| #recv_request | On the server side, receive a request from the client. | 
| #send_reply | On the server side, send a reply to the client. | 
| #send_request | On the client side, send a request to the server. | 
| #set_sockopt, | |
| #shutdown | Graceful shutdown. | 
| #stream | Get the socket. | 
| #accept_or_shutdown, #close_shutdown_pipe | |
Constructor Details
    .new(uri, soc, config = {}, server_mode = false)  ⇒ DRbUNIXSocket 
  
# File 'lib/drb/unix.rb', line 62
def initialize(uri, soc, config={}, server_mode = false) super(uri, soc, config) set_sockopt(@socket) @server_mode = server_mode @acl = nil end
Class Method Details
.open(uri, config)
[ GitHub ].open_server(uri, config)
[ GitHub ]# File 'lib/drb/unix.rb', line 34
def self.open_server(uri, config) filename, = 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)
[ GitHub ].temp_server (private)
[ GitHub ]# File 'lib/drb/unix.rb', line 72
def self.temp_server tmpdir = Dir::tmpdir n = 0 while true begin tmpname = sprintf('%s/druby%d.%d', tmpdir, $$, n) lock = tmpname + '.lock' unless File.exist?(tmpname) or File.exist?(lock) Dir.mkdir(lock) break end rescue raise "cannot generate tempfile '%s'" % tmpname if n >= Max_try #sleep(1) end n += 1 end soc = UNIXServer.new(tmpname) Dir.rmdir(lock) soc end
.uri_option(uri, config)
[ GitHub ]Instance Method Details
#accept
[ GitHub ]# File 'lib/drb/unix.rb', line 105
def accept s = accept_or_shutdown return nil unless s self.class.new(nil, s, @config) end
#close
[ GitHub ]# File 'lib/drb/unix.rb', line 95
def close return unless @socket shutdown # DRbProtocol#shutdown path = @socket.path if @server_mode @socket.close File.unlink(path) if @server_mode @socket = nil close_shutdown_pipe end
#set_sockopt(soc)
[ GitHub ]# File 'lib/drb/unix.rb', line 111
def set_sockopt(soc) # no-op for now end