+ size_t pos = addr.find_first_of(':');
+ if (pos == std::string::npos)
+ throw Error("Missing transport name.");
+ transport = toTransport(addr.substr(0, pos));
+ addr = addr.substr(pos + 1);
+ if (addr.empty())
+ throw Error("Missing address to connect to.");
+ pos = addr.find_first_of('@');
+ if (pos != std::string::npos) {
+ key = addr.substr(0, pos);
+ addr = addr.substr(pos + 1);
+ if (addr.empty())
+ throw Error("Missing address to connect to.");
+ }
+ if (transport == STG::SGCP::UNIX)
+ {
+ address = addr;
+ return;
+ }
+ pos = addr.find_first_of(':');
+ if (pos == std::string::npos)
+ throw Error("Missing port.");
+ address = addr.substr(0, pos);
+ if (str2x(addr.substr(pos + 1), port))
+ throw Error("Invalid port value.");
+}
+
+STG_CLIENT::STG_CLIENT(const std::string& address)
+ : m_config(address),
+ m_proto(m_config.transport, m_config.key)
+{
+ try {
+ m_proto.connect(m_config.address, m_config.port);
+ } catch (const STG::SGCP::Proto::Error& ex) {
+ throw Error(ex.what());