The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 03-17-2002
Mistwolf Mistwolf is offline
Registered User
 

Join Date: Mar 2002
Posts: 1
Simple Network Program Difficulties

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
Reply With Quote
Forum Sponsor