On Tue, 28 Nov 2006, umesh pandey wrote:
After converting FGNetFDM structure(given in net_fdm.cxx) by using htonf,htond or htonl, do we need to convert the structure into char packets and send to FGFS. I am using FGFS 0.9.3.
Hi! Well, when you have used hton*() on your struct it should (hopefully[1])have the right (i.e. the one you should send) represantation in memory so you can just reinterpret your struct as a char array of the right form:
typedef struct {...} mystruct_t; mystruct_t anInstance; char * sendbuffer = (char *)&anInstance; This pointer could then be passed to sendto(2) or similar.[1] The critical point here is to be sure that the compiler does not insert any padding into the struct. Alternatively one could manually and explicitly move the contents of the struct into a char array to be sure it has exactly the right form (this is what I would do since it also documents the actual packet format a bit more clearly).
Cheers, Anders -- --------------------------------------------------------------------------- Anders Gidenstam Algorithms and Complexity Group Phone: +49 (0) 681 9325 116 Max-Planck-Institut für Informatik Fax: +49 (0) 681 9325 199 Stuhlsatzenhausweg 85 Email: [EMAIL PROTECTED] 66123 Saarbrücken, Germany WWW: http://www.mpi-inf.mpg.de/~andersg ---------------------------------------------------------------------------
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel