Sha256: 3b149c4399850bf6065e1e4eb380950a828c5e531ad34c546624ce64ab2de004

Contents?: true

Size: 948 Bytes

Versions: 1

Compression:

Stored size: 948 Bytes

Contents

require "socket"

module Celluloid
  module IO
    # UNIXSocket with combined blocking and evented support
    class UNIXSocket < Stream
      # Open a UNIX connection.
      def self.open(socket_path, &block)
        new(socket_path, &block)
      end

      # Convert a Ruby UNIXSocket into a Celluloid::IO::UNIXSocket
      # DEPRECATED: to be removed in a future release
      # @deprecated use .new instead
      def self.from_ruby_socket(ruby_socket)
        new(ruby_socket)
      end

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

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

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
celluloid-io-0.17.3 lib/celluloid/io/unix_socket.rb