[En-Nut-Discussion] Sending Numerical Data

MUHAMMAD AZEEM AZAM muhammadazeemazam786 at yahoo.com
Wed Jan 31 17:38:44 CET 2007


Hi 
   
  I have to send now more than 128 Bytes of Data. (1 Packet = 128 BYtes)
  The first two Bytes are numerical Numbers that shows tha packet.
  The code below (Please if u can make it better then it would be helpful)
  its working and showing numbers from 0 t0 99.
  But i think its in ASCII Format.
  1) How can i send in Binary.
  2) Since 2-Bytes so i need  nos from 0 to 65536.
  hows that possible
  ------------------------------------------------------
  unsigned int packet_number_L = '0';
unsigned char packet_number_R = '0';
  ---------------------------------------------------------
  its the part of main()
   
  if (strncmp(buff, "packet\n", got_data) == 0) //If Match 
 
 {
  int p_size = 128;
  char p_array[p_size];
  int index = 0;
  
  p_array[0]= packet_number_L;
  p_array[1]= packet_number_R;
  
  for(index=2;index<p_size;index++)
   {
    p_array[index] = rand()%26+'a';
   }
  
  fwrite(p_array,sizeof(p_array),1,TCPStream);
  
    
  if(packet_number_R == 57)
  {
  packet_number_R = '0';
  packet_number_L++;
  }
  else
  {
  packet_number_R ++;
  }
  
  if(packet_number_R == 57 && packet_number_L ==57)
  {
   packet_number_R = '0';
   packet_number_L = '0';
  }
    
 continue;
 }
  ------------------------------------

 
---------------------------------
Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives. Check it out.


More information about the En-Nut-Discussion mailing list