}
for (unsigned int i = 0; i < hosts.size(); ++i) {
- servers_.push_back(pair<string, int>(hosts[i], ports[i]));
+ addServer(hosts[i], ports[i]);
}
}
{
}
+TSocketPool::TSocketPool(const string& host, int port) : TSocket(),
+ numRetries_(1),
+ retryInterval_(60),
+ maxConsecutiveFailures_(1),
+ randomize_(true),
+ alwaysTryLast_(true)
+{
+ addServer(host, port);
+}
+
TSocketPool::~TSocketPool() {
close();
}
+void TSocketPool::addServer(const string& host, int port) {
+ servers_.push_back(pair<string, int>(host, port));
+}
+
void TSocketPool::setNumRetries(int numRetries) {
numRetries_ = numRetries;
}
*/
TSocketPool(const std::vector<std::pair<std::string, int> > servers);
+ /**
+ * Socket pool constructor
+ *
+ * @param host single host
+ * @param port single port
+ */
+ TSocketPool(const std::string& host, int port);
+
/**
* Destroyes the socket object, closing it if necessary.
*/
virtual ~TSocketPool();
+ /**
+ * Add a server to the pool
+ */
+ void addServer(const std::string& host, int port);
+
/**
* Sets how many times to keep retrying a host in the connect function.
*/