1 #include "stg/sgcp_proto.h"
3 #include "stg/sgcp_transport.h"
8 using STG::SGCP::Proto;
10 Proto::Error::Error(const std::string& message)
11 : runtime_error(message)
15 : runtime_error(strerror(errno))
18 Proto::Proto(TransportType transport, const std::string& key)
19 : m_transport(TransportProto::create(transport, key))
28 void Proto::connect(const std::string& address, uint16_t port)
31 m_transport->connect(address, port);
32 } catch (const TransportProto::Error& ex) {
33 throw Error(ex.what());
37 void Proto::writeAllBuf(const void* buf, size_t size)
39 const char* pos = static_cast<const char*>(buf);
41 ssize_t res = m_transport->write(pos, size);
51 void Proto::readAllBuf(void* buf, size_t size)
53 char* pos = static_cast<char*>(buf);
55 ssize_t res = m_transport->read(pos, size);