Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object serialization

Status
Not open for further replies.

fenris

Programmer
May 20, 1999
824
CA
I want to be able to transfer an object from one PC over the network to another PC. I have been reading that object serialization is what I am looking for.

Currently I have my own routines within the objects that serializes the data into a specifc string that contains all the information that the object contains. When the client PC receives the string data, it is able to create a duplicate object based on the string.

I am wondering if there is an easier way to do this? I am also having a bit of a problem transmitting collections.

Any suggestions?

Troy Williams B.Eng.
fenris@hotmail.com

 
Why not use COM for W2K or MTS for NT.

You can have a DLL on one PC and use it from another PC. Craig, mailto:sander@cogeco.ca

Remember not to name the Lambs...
It only makes the chops harder to swallow
 
The problem with that is, you can't "transfer" an object to a unix box running java. The idea, that I've gathered, from reading resources on the net is that serialization is used for this. Coupling it with XML gives it a platform independant flavour. Obviously, a java class would be constructed on the VB classes specs, but the data would pass between them independently.

Unfortunately I have found very limited explainations of object serialization for VB 6. There are a large number of resources for vb.net.

I am looking for some simple examples. I have implemented serialization, but I am not sure it is the best way. Basically I convert the class variables into a string (just as delimited string) and prefix on a header describing how long the string is (minus the header). the string looks something like this: header|string. This makes the header easy to identify from the string that is received from the winsock control. From there, after the data is received, the code then parses out the data and creates a new object on the machine.

Thanks for the reply though...
Troy Williams B.Eng.
fenris@hotmail.com

 
Your way over my head now... I've just started using XML in the past week.

but best of luck. Craig, mailto:sander@cogeco.ca

Remember not to name the Lambs...
It only makes the chops harder to swallow
 
You may wish to look at the Microsoft Soap Toolkit. It has sample code that can use used, and makes references to Visual Basic Add-Ins that are helpful in sending and recieving objects through SOAP and XML.

This is not trival stuff, though. The implementation of the soap listener, transmitters (not sure if that is the lingo, but its close) is not for the faint of heart.

And, the SOAP Toolkit is just an interim technology between COM and .NET. Furthermore, you might not be able to get past the web-centric nature of the listener (the requirement of a WSDL file, the use of a web server and its ASP pages as a listener).

SOAP is one way to send simple objects across the Internet though.

Take a look at least. Search on "SOAP Toolkit" at for more info.

Regards,
Tom Rogers
TJRTech, Inc.
 
You can look at SOAP and XML if you like, but for simple stuff consider using a PropertyBag (a much overlooked object), whgich is great for serialising and deserialising objects. Check out the documentation for further info.
 
fenris -

That's pretty much how you do it. You can write your object's state to a string in a private format (which it sounds like what you've done), but you might want to watch out for writing numeric values, since most Unix boxes have CPU's with a different byte order than Intel processors. If you write the values as pure ASCII (well, ANSI) strings you should be OK. Oh - watch out for code-page issues. Try and limit yourself to the 96 or so printable ASCII characters.

If you're *really* not sure what kind of system you'll be talking to, look at using XML as the format for serializing your objects. Transferring info between different systems is what it's made for.

Chip H.
 
Thanks Chip, that is where my research was leading me... Troy Williams B.Eng.
fenris@hotmail.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top