thanks for the info - but is it reordered when the application layer on the other side of the network finally gets it. hmmm... what i want to know is i can write and read structures to and from the network without any problems - it it that, on the other end it is put back in order ?
i was actually writing a DNS resolver but the DNS server doesnt seem to understand my structure any clue why ? but if i send my packet with the various fields set in such a way that :
unsigned short query_id = (0x1100) is what i desire to send but i knowingly set it to (0x0011) knowing that it wud be reversed when transmitted, everything works fine. Can anyone tell me why ?
i could resolve names for example i tried resolving "www.google.com" i got exactly the same results which i got when i used
[amith@testbed# dig @xxx.xxx.xxx.xxx www.google.com ( dig - dns info gropher )
of course after i made changes to the code and setting every feild with new values - ( 0x1100) was changed to (0x0011) before the sendto ( ) call.
cheers, amith
Vijaymahantesh Kalakoti wrote:
Hi amith,
As u know the character array is stored sequentially (in the local machine) starting from lowest address & moving towards higher addresses, so when they are transmitted through network ,they are transmitted in sequential order as they are stored.
But the integers are not stored like array. integers are stored in the local machine in two ways
1. big-endian 2. little-endian
the choice of storage is machine dependent.
That's why u don't get them as like array's.
thanks & regards
vijay kalkoti
On Tue, 10 Feb 2004, Amith wrote:
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/
------------------------------------------------------------------------
***********************************************************************
PLEASE VISIT US AT STAND E13B, AT 3GSM WORLD CONGRESS 2004, CANNES.
********************************************************************
SASKEN BUSINESS DISCLAIMER
This message may contain confidential, proprietary or legally Privileged information. In case you are not the original intended Recipient of the message, you must not, directly or indirectly, use, Disclose, distribute, print, or copy any part of this message and you are requested to delete it and inform the sender. Any views expressed in this message are those of the individual sender unless otherwise stated. Nothing contained in this message shall be construed as an offer or acceptance of any offer by Sasken Communication Technologies Limited ("Sasken") unless sent with that express intent and with due authority of Sasken. Sasken has taken enough precautions to prevent the spread of viruses. However the company accepts no liability for any damage caused by any virus transmitted by this email.
***********************************************************************
-- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/