www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript
electronics



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

↑ ↓ ← "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
→ 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
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
↑ ↓ → "Masterchief" <ronald.putz kapsch.net> writes:
Hy!

 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?

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
→ "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