Class: Celluloid::IO::UNIXServer

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

Overview

UNIXServer with combined blocking and evented support

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(socket_path) ⇒ UNIXServer

Returns a new instance of UNIXServer.



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/celluloid/io/unix_server.rb', line 14

def initialize(socket_path)
  begin
    @server = ::UNIXServer.new(socket_path)
  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

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



28
29
30
31
# File 'lib/celluloid/io/unix_server.rb', line 28

def accept
  Celluloid::IO.wait_readable(@server)
  accept_nonblock
end

#accept_nonblockObject



33
34
35
# File 'lib/celluloid/io/unix_server.rb', line 33

def accept_nonblock
  Celluloid::IO::UNIXSocket.new(@server.accept_nonblock)
end

#to_ioObject



37
38
39
# File 'lib/celluloid/io/unix_server.rb', line 37

def to_io
  @server
end