www.digitalmars.com         C & C++   DMDScript  

c++ - Sending own class as binary data over socket

reply "Masterchief" <ronald.putz kapsch.net> writes:
Hy!

I am trying to develop a Client Server Communication over TCP/IP.
I want to use an own Message class and send this class as binary data over a 
socket.
I want to use stream operators for reading and writing to the stream.

How do I convert a class to binary data to send it?
How do I use a socket and stream operators for reading and writing?

Thanks a lot.

Examples would help a lot:-)

Ronny 
Jan 22 2007
next sibling parent Brecht Machiels <brecht mos6581.org> writes:
Hello,

you might want to look into the CORBA framework for the passing of 
objects. Using this framework you will not have to worry about socket 
programming.

There should be plenty of documentation on socket programming on the 
net. A good book might be better though.

Regards,
Brecht

Masterchief wrote:
 Hy!
 
 I am trying to develop a Client Server Communication over TCP/IP.
 I want to use an own Message class and send this class as binary data over a 
 socket.
 I want to use stream operators for reading and writing to the stream.
 
 How do I convert a class to binary data to send it?
 How do I use a socket and stream operators for reading and writing?
 
 Thanks a lot.
 
 Examples would help a lot:-)
 
 Ronny 
 
 
Jan 22 2007
prev sibling next sibling parent reply Bertel Brander <bertel post4.tele.dk> writes:
Masterchief skrev:
 Hy!
 
 I am trying to develop a Client Server Communication over TCP/IP.
 I want to use an own Message class and send this class as binary data over a 
 socket.
 I want to use stream operators for reading and writing to the stream.
 
 How do I convert a class to binary data to send it?
 How do I use a socket and stream operators for reading and writing?
 
 Thanks a lot.
 
 Examples would help a lot:-)
I have some code that could be used as a start, but I have to adjust it to Digital Mars. There are some questions: Do you have full control of both ends of the socket? Do both ends use the same hardware and compiler? Do the classes that is to be send use virtual methods? Do the classes have pointers to data, or is it only POD and arrays? -- Just another homepage: http://damb.dk But it's mine - Bertel
Jan 22 2007
parent "Masterchief" <ronald.putz kapsch.net> writes:
Hy!

 There are some questions:
 Do you have full control of both ends of the socket?
Yes
 Do both ends use the same hardware and compiler?
Yes
 Do the classes that is to be send use virtual methods?
NO
 Do the classes have pointers to data, or is it only POD and arrays?
I think I will just use arrays. The code would be very helpfull. Thanks a lot. "Bertel Brander" <bertel post4.tele.dk> schrieb im Newsbeitrag news:ep33ni$13p1$1 digitaldaemon.com...
 Masterchief skrev:
 Hy!

 I am trying to develop a Client Server Communication over TCP/IP.
 I want to use an own Message class and send this class as binary data 
 over a socket.
 I want to use stream operators for reading and writing to the stream.

 How do I convert a class to binary data to send it?
 How do I use a socket and stream operators for reading and writing?

 Thanks a lot.

 Examples would help a lot:-)
I have some code that could be used as a start, but I have to adjust it to Digital Mars. There are some questions: Do you have full control of both ends of the socket? Do both ends use the same hardware and compiler? Do the classes that is to be send use virtual methods? Do the classes have pointers to data, or is it only POD and arrays? -- Just another homepage: http://damb.dk But it's mine - Bertel
Jan 23 2007
prev sibling parent "Pavel Vozenilek" <pavel_vozenilek yahoo.co.uk> writes:
"Masterchief" wrote:

 I am trying to develop a Client Server Communication over TCP/IP.
 I want to use an own Message class and send this class as binary data over 
 a socket.
 I want to use stream operators for reading and writing to the stream.

 How do I convert a class to binary data to send it?
 How do I use a socket and stream operators for reading and writing?
On http://www.codeproject.com/threads/Rcf_Ipc_For_Cpp.asp is a tool to serialize any C++ class and send it over the wire. Once DMC will be able to deal with Boost this library should work as well. IMHO DMC has a good chance to reach this state, based on the feedback for bug reports. /Pavel
Jan 24 2007