Greetings,
I want to send a userdefined structure over a network, I would like to know if there is a way to convert a structure into string.
LANG - C++; COMPILER - g++;
Bye.
------------------------------------------------- Sify Mail - now with Anti-virus protection powered by Trend Micro, USA. Know more at http://mail.sify.com
Sify Power mail- a Premium Service from Sify Mail! know more at http://mail.sify.com
On Thu, 20 Mar 2003 16:52:18 +0500 (IST) amish munshi wrote:
I want to send a userdefined structure over a network, I would like to know if there is a way to convert a structure into string.
LANG - C++; COMPILER - g++;
Try http://xparam.sourceforge.net or http://www.gnu.org/software/commonc++
amish munshi wrote:
I want to send a userdefined structure over a network, I would like to know if there is a way to convert a structure into string.
LANG - C++; COMPILER - g++;
my_object.to_string() should return the string. But you have to write the implementation. :->
-Manish
amish munshi writes:
Greetings,
I want to send a userdefined structure over a network, I would like to know if there is a way to convert a structure into string.
LANG - C++; COMPILER - g++;
There is no need to convert a structure into a string. Trust the C library to make it easy for you.
The following is an elegant solution
Here is a code snippet for you
#include <sys/uio.h>
// define a structure of type iovec iovec iov[0];
// rtt_hdr is my header structure // for RTT packet. Pass the base address // and the size of the header
iov[0].iov_base = &rtt_hdr; iov[0].iov_len = sizeof(rtt_hdr);
then use the readv/writev calls to read and write to the network socket.
refer pg 357-358 of Unix Network programming - Richard Stevens Volume 1 ( I am not qouting this from memory - just that I located the book nearby ;)
Also refer the manpages of readv / writev C library calls.
Vinayak Hegde APGDST Student NCST-JUHU