Example #1
0
        void Connection::Receive(std::vector<int8_t>& msg)
        {
            if (!connected)
                IGNITE_ERROR_1(IgniteError::IGNITE_ERR_ILLEGAL_STATE, "Connection is not established");

            msg.clear();

            OdbcProtocolHeader hdr;

            int64_t received = ReceiveAll(reinterpret_cast<int8_t*>(&hdr), sizeof(hdr));

            if (received != sizeof(hdr))
                IGNITE_ERROR_1(IgniteError::IGNITE_ERR_GENERIC, "Can not receive message header");

            if (hdr.len < 0)
                IGNITE_ERROR_1(IgniteError::IGNITE_ERR_GENERIC, "Message lenght is negative");

            if (hdr.len == 0)
                return;

            msg.resize(hdr.len);

            received = ReceiveAll(&msg[0], hdr.len);

            if (received != hdr.len)
            {
                msg.resize(received);

                IGNITE_ERROR_1(IgniteError::IGNITE_ERR_GENERIC, "Can not receive message body");
            }
        }
Example #2
0
        void Connection::Send(const int8_t* data, size_t len)
        {
            if (!connected)
                IGNITE_ERROR_1(IgniteError::IGNITE_ERR_ILLEGAL_STATE, "Connection is not established");

            common::FixedSizeArray<int8_t> msg(len + sizeof(OdbcProtocolHeader));

            OdbcProtocolHeader *hdr = reinterpret_cast<OdbcProtocolHeader*>(msg.GetData());

            hdr->len = static_cast<int32_t>(len);

            memcpy(msg.GetData() + sizeof(OdbcProtocolHeader), data, len);

            size_t sent = SendAll(msg.GetData(), msg.GetSize());

            if (sent != len + sizeof(OdbcProtocolHeader))
                IGNITE_ERROR_1(IgniteError::IGNITE_ERR_GENERIC, "Can not send message");
        }
Example #3
0
        void Connection::Send(const int8_t* data, size_t len)
        {
            if (!connected)
                IGNITE_ERROR_1(IgniteError::IGNITE_ERR_ILLEGAL_STATE, "Connection is not established");

            OdbcProtocolHeader hdr;

            hdr.len = static_cast<int32_t>(len);

            size_t sent = SendAll(reinterpret_cast<int8_t*>(&hdr), sizeof(hdr));

            if (sent != sizeof(hdr))
                IGNITE_ERROR_1(IgniteError::IGNITE_ERR_GENERIC, "Can not send message header");

            sent = SendAll(data, len);

            if (sent != len)
                IGNITE_ERROR_1(IgniteError::IGNITE_ERR_GENERIC, "Can not send message body");
        }