In Files

  • mrbgems/mruby-socket/mrblib/socket.rb

UNIXServer

Public Class Methods

new(path) click to toggle source
 
               # File mrbgems/mruby-socket/mrblib/socket.rb, line 524
def initialize(path)
  fd = Socket._socket(Socket::AF_UNIX, Socket::SOCK_STREAM, 0)
  begin
    super(fd)
    Socket._bind(fd, Socket.pack_sockaddr_un(path))
    self.listen(5)
  rescue => e
    IO._sysclose(fd) rescue nil
    raise e
  end

  if block_given?
    begin
      yield self
    ensure
      self.close rescue nil unless self.closed?
    end
  end
end
            

Public Instance Methods

accept() click to toggle source
 
               # File mrbgems/mruby-socket/mrblib/socket.rb, line 544
def accept
  fd = self.sysaccept
  begin
    sock = UNIXSocket.for_fd(fd)
  rescue
    IO._sysclose(fd) rescue nil
  end
  sock
end
            
accept_nonblock() click to toggle source
 
               # File mrbgems/mruby-socket/mrblib/socket.rb, line 554
def accept_nonblock
  begin
    self._setnonblock(true)
    self.accept
  ensure
    self._setnonblock(false)
  end
end
            
listen(backlog) click to toggle source
 
               # File mrbgems/mruby-socket/mrblib/socket.rb, line 563
def listen(backlog)
  Socket._listen(self.fileno, backlog)
  0
end
            
sysaccept() click to toggle source
 
               # File mrbgems/mruby-socket/mrblib/socket.rb, line 568
def sysaccept
  Socket._accept(self.fileno)
end