110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
# File 'lib/right_support/db/cassandra_model.rb', line 110
def open
begin
addrinfo = ::Socket::getaddrinfo(@host, @port).first
@handle = ::Socket.new(addrinfo[4], ::Socket::SOCK_STREAM, 0)
sockaddr = ::Socket.sockaddr_in(addrinfo[1], addrinfo[3])
begin
@handle.connect_nonblock(sockaddr)
rescue Errno::EINPROGRESS
resp = IO.select(nil, [@handle], nil, @timeout) begin
@handle.connect_nonblock(sockaddr)
rescue Errno::EISCONN
end
end
@handle
rescue StandardError => e
raise TransportException.new(TransportException::NOT_OPEN, "Could not connect to #{@desc}: #{e}")
end
end
|