I'm working on a couple of programs, client/server. I'm using winsock library to handle data transfer between the two programs. I'm having a problem when it comes to sending int values, they must be converted to (char *) since that's the data type of the buffers used in the socket Send() and Recv() functions. to elaborate, consider the following:
unsigned char rnd;
int noncer =0;
// Generating a random number
noncer = (int)rnd;
// These two lines produce the same output which is 1244556
cout <<"\n Noncer :" << noncer << "\n";
cout <<"\n Noncer char :" << (int)non1 << "\n";
// Reading the nonce identifier
RecieveMessage(socket, String, number_of_bytes);
client_nonce = (int)String;
// this results in 1244588 !!
cout<<"\n the nonce is:"<<client_nonce <<endl;
If anyone can tell me what's causing the change of data i'd really appreciate it.
Thank you all in advance.