Since your array contains values like 65000 which can't be sent as a single byte, it's reasonable to assume you intend to send each value as two bytes.
Given that, the data-values don't need to be converted at all; rather only the type of the pointer does (so that the send() call will compile). So this should be sufficient:
unsigned short array[10] = {65000, 0, 6000, 15000, 100, 50, 1000, 10, 5000, 2000};
const uint8_t *data = reinterpret_cast<const uint8_t *>(array);
send(data, sizeof(array));
Note that the send() call is specifying sizeof(array) and NOT sizeof(data); since data is a pointer, its size is either 4 or 8 bytes (depending on your CPU architecture) and has nothing to do with the number of bytes of data you want to send!
The receiving side is similar:
uint16_t buf[10];
uint8_t len = sizeof(buf);
uint8_t * data = reinterpret_cast<uint8_t *>(buf);
receive(data, &len);
Note that after receive() returns, len will indicate the number of bytes received, so the number of uint16_t values received will be half that:
int numShortsReceived = len/sizeof(uint16_t);
for (int i=0; i<numShortsReceived; i++) printf("Received short #%i = %u\n", i, buf[i]);
Another note: the above code doesn't handle big-end/little-endian conversion. If you can guarantee that both the sender and the receiver will be running on a CPU with the same endian-ness, that's not a problem. If OTOH you need this code to work correctly across mixed-CPUs (i.e. with a big-endian sender sending to a little-endian receiver, or vice-versa), then you'll want to have your sending code convert your each of your uint16_t's to network/big-endian before sending them (via htons()) and also to have your receiving code convert each of the received uint16_t's from network/big-endian to its local endian-ness (via ntohs()) after receiving them (but before trying to use them for anything).
unsigned char low_byte = ushort & 0xff; unsigned char high_byte = (ushort >> 8) & 0xff;unsigned short(which is a non-negligible consideration). No particular conversion is required for this, other than a couple of pointer casts.lenbe of typeuint8_tin yoursend()andreceive()functions means that you will never be able to send or receive more than 255 bytes in a single call, which seems a bit limiting. If you have the ability to change it, you might want to change it touint32_tinstead.