Class: Mongo::UNIXSocket

Inherits:
TCPSocket show all
Defined in:
lib/mongo/util/unix_socket.rb

Overview

Wrapper class for Socket

Emulates UNIXSocket with operation and connection timeout sans Timeout::timeout

Instance Attribute Summary

Attributes included from SocketUtil

#pid, #pool

Instance Method Summary collapse

Methods inherited from TCPSocket

#connect, #read, #send

Methods included from SocketUtil

#checkin, #checkout, #close, #closed?

Constructor Details

#initialize(socket_path, port = :socket, op_timeout = nil, connect_timeout = nil) ⇒ UNIXSocket



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/mongo/util/unix_socket.rb', line 10

def initialize(socket_path, port=:socket, op_timeout=nil, connect_timeout=nil)
  @op_timeout = op_timeout
  @connect_timeout = connect_timeout

  @address = socket_path
  @port = :socket # purposely override input

  @socket_address = Socket.pack_sockaddr_un(@address)
  @socket = Socket.new(Socket::AF_UNIX, Socket::SOCK_STREAM, 0)
  connect
end