Class: Celluloid::IO::UNIXSocket

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

Overview

UNIXSocket with combined blocking and evented support

Constant Summary

Constants inherited from Stream

Stream::BLOCK_SIZE

Instance Attribute Summary

Attributes inherited from Stream

#sync

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Stream

#<<, #close, #each, #each_byte, #eof?, #flush, #getc, #gets, #print, #printf, #puts, #read, #readchar, #readline, #readlines, #readpartial, #sysread, #syswrite, #ungetc, #wait_readable, #wait_writable, #write

Constructor Details

#initialize(socket_path, &block) ⇒ UNIXSocket

Open a UNIX connection.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/celluloid/io/unix_socket.rb', line 23

def initialize(socket_path, &block)
  super()
  
  # Allow users to pass in a Ruby UNIXSocket directly
  if socket_path.is_a? ::UNIXSocket
    @socket = socket_path
    return
  end

  # FIXME: not doing non-blocking connect
  @socket = if block
    ::UNIXSocket.open(socket_path, &block)
  else
    ::UNIXSocket.new(socket_path)
  end
end

Class Method Details

.from_ruby_socket(ruby_socket) ⇒ Object

Convert a Ruby UNIXSocket into a Celluloid::IO::UNIXSocket DEPRECATED: to be removed in a future release



18
19
20
# File 'lib/celluloid/io/unix_socket.rb', line 18

def self.from_ruby_socket(ruby_socket)
  new(ruby_socket)
end

.open(socket_path, &block) ⇒ Object

Open a UNIX connection.



12
13
14
# File 'lib/celluloid/io/unix_socket.rb', line 12

def self.open(socket_path, &block)
  self.new(socket_path, &block)
end

Instance Method Details

#to_ioObject



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

def to_io
  @socket
end