getpeereid

basicsocket.getpeereid => [euid, egid]
Instance Public methods

Returns the user and group on the peer of the UNIX socket. The result is a two element array which contains the effective uid and the effective gid.

Socket.unix_server_loop("/tmp/sock") {|s|
  begin
    euid, egid = s.getpeereid

    # Check the connected client is myself or not.
    next if euid != Process.uid

    # do something about my resource.

  ensure
    s.close
  end
}
doc_ruby_on_rails
2015-03-31 00:48:50
Comments
Leave a Comment

Please login to continue.