I'm trying to write 2 programs, client & server, that communicate with integers, however, all resources I have found on the net assume that you want to send and recieve information as a character array. I don't want to send my integers as characters, I want to send them as ints (casting them to characters makes them take more space). Does anyone know how to do this? Here is my working code for sending & receiving characters:
char rcvMessageChars[STRING_SIZE]; /* char message */
char sndMessageChars[STRING_SIZE];
write(newsockfd, sndMessageChars, STRING_SIZE);
msgLength = read(newsockfd, rcvMessageChars, STRING_SIZE);
Another quick question - is there any *easy* way to generate random integers in a certain range? i.e. 1-1000 instead of 1-2^16 ?
How about generating random lowercase characters a-z?
Thanks in advance for your help