How to send double value over TCP?

  arduino-esp8266, c++, double-pointer, tcp

i have an ESP8266 which sends data to Matlab. I have to send double values, but i can only send uint8 or chars. So the idea is to convert the double into int by bit representation.

The function im using is client.write() from the ESP8266WiFi Library:

size_t WiFiClient::write(const uint8_t *buf, size_t size)
    if (!_client || !size)
        return 0;
    return _client->write((const char*)buf, size);

size_t WiFiClient::write(Stream& stream)
    // (this method is deprecated)

    if (!_client || !stream.available())
        return 0;
    // core up to 2.7.4 was equivalent to this
    return stream.sendAll(this);

I tried this and i get 8 bytes on the Server but it doesn’t seem right:
I captured the inputs with wireshark.

      if (sFlag)
        double test =  acc_z;
        /*char buffer[6];

        dtostrf(test, 4, 2, buffer);
        client.write(test, 6);*/

        uint8_t *array = reinterpret_cast<uint8_t*>(&test);


        sFlag = false;


I hope somebody can help me or give me a hint, to archieve what i want.

Thank you.

Source: Windows Questions C++