Class: Celluloid::IO::UNIXServer

Inherits:
Socket
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/celluloid/io/unix_server.rb

Overview

UNIXServer with combined blocking and evented support

Constant Summary

Constants inherited from Socket

Socket::Constants

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Socket

new, #to_io, try_convert

Constructor Details

#initialize(socket_path) ⇒ UNIXServer #initialize(socket) ⇒ UNIXServer

Returns a new instance of UNIXServer.

Overloads:

  • #initialize(socket_path) ⇒ UNIXServer

    Parameters:

    • socket_path (String)
  • #initialize(socket) ⇒ UNIXServer

    Parameters:

    • socket (::UNIXServer)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/celluloid/io/unix_server.rb', line 19

def initialize(socket)
  if socket.kind_of? ::BasicSocket
    # socket
    fail ArgumentError, "wrong kind of socket (#{socket.class} for UNIXServer)" unless socket.kind_of? ::UNIXServer
    super(socket)
  else
    begin
      super(::UNIXServer.new(socket))
    rescue => ex
      # Translate the EADDRINUSE jRuby exception.
      raise unless RUBY_PLATFORM == 'java'
      if ex.class.name == "IOError" && # Won't agree to .is_a?(IOError)
         ex.message.include?("in use")
        raise Errno::EADDRINUSE.new(ex.message)
      end
      raise
    end
  end
end

Class Method Details

.open(socket_path) ⇒ Object



10
11
12
# File 'lib/celluloid/io/unix_server.rb', line 10

def self.open(socket_path)
  self.new(socket_path)
end

Instance Method Details

#acceptObject



39
40
41
42
# File 'lib/celluloid/io/unix_server.rb', line 39

def accept
  Celluloid::IO.wait_readable(to_io)
  accept_nonblock
end

#accept_nonblockObject



44
45
46
# File 'lib/celluloid/io/unix_server.rb', line 44

def accept_nonblock
  Celluloid::IO::UNIXSocket.new(to_io.accept_nonblock)
end