samedi 9 avril 2022

How to store a rand() variable?

I am trying to store the value of a rand() variable. I don't know if the questions is going to make much sense. I send tcph_seqnum to the Server, the Server reads receives: 1732610923. Then, I try to use the same variable again, let's say with a printf statement, and I get: 193094224.

This is my code below:

u_int16_t tcph_seqnum = rand();
write(clientSocket, &tcph_seqnum, sizeof(tcph_seqnum)); /* server receives 1732610923 */
printf("%d\n", tcph_seqnum); /* prints to the console 193094224*/

How can I reuse the same value sent to the Server? Store in a variable without the value changing?




Aucun commentaire:

Enregistrer un commentaire