Hello all, I am a newb at this so bare with me here....
I have created a client/server program that communicate with each other. My goal is to compute the data rate of a link between two devices. The way I do this is by simply sending a message of some size to the other device (for now I am working with only two nodes) and computing the arrival times etc.
I have a custom message struct that has variables for when the message is sent and received and some other required info. That's not important for now. All I want to know is, without modifying the contents of the struct, I want to send different size data with my custom messages for calculating the data rate. Basically, how can I increase the size/ append extra bytes to the message struct to be sent through a socket (currently using UDP socket)?
For debugging purposes I simply created an empty char data and cast my message struct to the data:
union my_message *msg;
msg = (union my_message *) data;
I sent it through the socket:
sendto(socket, (char *)msg, 1024, ....);
Apparently the sendto function is successful and returns 1024 bytes written even though the actual data (custom message struct) is less than 1024. The server side also correctly receives 1024 bytes. I always thought I had to fill the array with dummy data, is that required? or is it enough just to create the empty array, cast my filled up struct to it and send it?
Thanks guys, just trying to wrap my head around this....