Network byte ordering ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi all,
i send this structure over the network using sockets (UDP) api .


struct temporary
{
   char name[10];
   unsigned short x;
}temp;

i assign :

strcpy(temp.name,"ABCDEFGHI");
temp.x = 0x1100;

Now i capture the packet sent from my system using Ethereal ( the packet capture tool ).
i observed that the string ( char name [10] ) was transmitted as expected i.e i could see the hex decimal values
for A,B......I in order. i.e 41 42 43 ........48 49 00 . But the integer variable ( unsigned short x) was transmitted as 0x00 0x11 ( as shown in ethereal ) and not as 0x1100 ( which was expected by me).


if it was something to do with "Network bye ordering " then :
why didn't it happen with the string (char name[10]) and only with the Integer var?
why was it (char name[10] ) transmitted as it is ?


i'am confused. Any pointers or explanations would be very much helpfull.

cheers,
Amith

PS: hope my question was clear.






-- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux