Sha256: a41aced460971532b5c3adfd1c341053a70f05176358de85893ab832010fb692

Contents?: true

Size: 755 Bytes

Versions: 3

Compression:

Stored size: 755 Bytes

Contents

class UNIXServer < UNIXSocket
  def initialize(path)
    @no_reverse_lookup = self.class.do_not_reverse_lookup
    @path              = path

    fd = RubySL::Socket::Foreign.socket(Socket::AF_UNIX, Socket::SOCK_STREAM, 0)

    Errno.handle('socket(2)') if fd < 0

    IO.setup(self, fd, 'r+', true)

    sockaddr = Socket.sockaddr_un(@path)
    status   = RubySL::Socket::Foreign.bind(descriptor, sockaddr)

    Errno.handle('bind(2)') if status < 0

    listen(Socket::SOMAXCONN)
  end

  def listen(backlog)
    RubySL::Socket.listen(self, backlog)
  end

  def accept
    RubySL::Socket.accept(self, UNIXSocket)[0]
  end

  def accept_nonblock
    RubySL::Socket.accept_nonblock(self, UNIXSocket)[0]
  end

  def sysaccept
    accept.fileno
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubysl-socket-2.1.2 lib/socket/unix_server.rb
rubysl-socket-2.1.1 lib/socket/unix_server.rb
rubysl-socket-2.1.0 lib/socket/unix_server.rb