Vault
4.1
|
Connects to each DNS resolved IP address for a host name, in order, until one succeeds or a specified timeout is reached. More...
#include <vsocket.h>
Public Member Functions | |
VSocketConnectionStrategyLinear (const VDuration &timeout) | |
virtual void | connect (const VString &hostName, int portNumber, VSocket &socketToConnect) const |
The VSocketConnectionStrategy interface to be implemented by concrete subclasses. |
Connects to each DNS resolved IP address for a host name, in order, until one succeeds or a specified timeout is reached.
This strategy makes most sense with IPv4 where DNS is supposed to return a randomized list of resolved addresses, thus achieving a form of round-robin connection balancing by always using the first address.
void VSocketConnectionStrategyLinear::connect | ( | const VString & | hostName, |
int | portNumber, | ||
VSocket & | socketToConnect | ||
) | const [virtual] |
The VSocketConnectionStrategy interface to be implemented by concrete subclasses.
Connects to the host name by resolving it and then applying the strategy to the resolved IP addresses. If the strategy fails (for whatever reason, be it a connect failure or a timeout) it shall throw a VException.
hostName | the name to resolve and connect to |
portNumber | the port number to connect to |
socketToConnect | if successful, this Vault socket object is to be mutated upon return to have the connected socket's host IP address and low-level VSocketID; for simple non-threaded strategies it is acceptable to simply call this object's connectToIPAddress() and leave the results in place if successful |
Implements VSocketConnectionStrategy.
Definition at line 673 of file vsocket.cpp.
References VString::chars(), VSocket::connectToIPAddress(), VSocketConnectionStrategy::mDebugIPAddresses, VSocket::resolveHostName(), and VException::what().