Board index » delphi » Sending objects over a socket connection

Sending objects over a socket connection

AAAAArgh!

I'm writing an application that sends information over a socket
connection. Now I want to send an(y) (generic) object over the
connection, but I can't find any support for this in Delphi. Is it
possible??
I've worked with Java earlier, and in Java there is an interface called
isSerializable that makes this possible.....
I'm aware of the possibility to send published data to a stream (as in
the TPersistent and TComponent-classes), but I think this is a bad
solution for me as I'm defining a base-class for everyone to use. If you
have to define the read- and write-functions for every field you might
want to add, you soon get tired....at least I am....

Please, Please (standing on my knees here) help me!

Thanx

Stefan Hilln
stefan.hil...@egs.ericsson.se /
d2hi...@dtek.chalmers.se

 

Re:Sending objects over a socket connection


AAAAArgh!

I'm writing an application that sends information over a socket
connection. Now I want to send an(y) (generic) object over the
connection, but I can't find any support for this in Delphi. Is it
possible??
I've worked with Java earlier, and in Java there is an interface called
isSerializable that makes this possible.....
I'm aware of the possibility to send published data to a stream (as in
the TPersistent and TComponent-classes), but I think this is a bad
solution for me as I'm defining a base-class for everyone to use. If you
have to define the read- and write-functions for every field you might
want to add, you soon get tired....at least I am....

Please, Please (standing on my knees here) help me!

Thanx

Stefan Hilln
stefan.hil...@egs.ericsson.se /
d2hi...@dtek.chalmers.se

Re:Sending objects over a socket connection


Since every object is unique you will be hard pressed to find a totally
generic
method of serializing data from a base class.  There are two solutions that
I am familiar with:

1. (easy one)  The most derrived object has to define a serialization
method
    that places the state of each member variable into a buffer.  This you
    have already discovered.

2.  If you can restrict the designer of the object to using your base class
and
     only data types that you supply then you can have these data types
     to contain the 'smartness' to be serialized automatically via the base
class.
     This is accomplished by having your data types (ydt) all be derrived
off of the
     same base class.  The base class would need to contain a static list
(one
     that is shared amoung all instances of obects instantiated off of this
class) that
     gets dynamically added to when the constructor of the ydt is fired.
The ydt's
     constructor would add the 'this' pointer to the list.  At
serialization time the
     base class whips through the list calling each ytd's serialization
method and
     there you have it.

have fun
-mike

Stefan Hilln <stefan.hil...@egs.ericsson.se> wrote in article
<33C5EF99.6...@egs.ericsson.se>...

Quote
> AAAAArgh!

> I'm writing an application that sends information over a socket
> connection. Now I want to send an(y) (generic) object over the
> connection, but I can't find any support for this in Delphi. Is it
> possible??
> I've worked with Java earlier, and in Java there is an interface called
> isSerializable that makes this possible.....
> I'm aware of the possibility to send published data to a stream (as in
> the TPersistent and TComponent-classes), but I think this is a bad
> solution for me as I'm defining a base-class for everyone to use. If you
> have to define the read- and write-functions for every field you might
> want to add, you soon get tired....at least I am....

> Please, Please (standing on my knees here) help me!

> Thanx

> Stefan Hilln
> stefan.hil...@egs.ericsson.se /
> d2hi...@dtek.chalmers.se

Other Threads