Method: Mongo::Socket::TCP#initialize
- Defined in:
- lib/mongo/socket/tcp.rb
#initialize(host, port, timeout, family, options = {}) ⇒ TCP
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes a new TCP socket.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/mongo/socket/tcp.rb', line 48 def initialize(host, port, timeout, family, = {}) if family.nil? raise ArgumentError, 'family must be specified' end super(timeout, ) @host, @port = host, port @family = family @socket = ::Socket.new(family, SOCK_STREAM, 0) begin (@socket) connect! rescue @socket.close raise end end |