vizskywalker 0 Report post Posted October 7, 2007 So, I am working on an extended media server application for personal use, and I'm currently using TcpListener and TcpClient objects to establish a network connection. This works fine, except that it would be really useful to be able to pass objects back and forth between the two application (server and client). If I have to switch the type of connection I am using, that's fine, but I was wondering if anyone knew of any way to pass objects back and forth. One thought I had was somehow getting a byte[] buffer of all of the object's data, send that, and then translate it back into an object, but I have no idea a) if that's possible and how to do that. Any ideas are helpful.Thanks,~Viz Share this post Link to post Share on other sites
faulty.lee 0 Report post Posted October 7, 2007 I haven't really tried this, but I've read about it quite a lot of times, and have look into it, just haven't got a chance to apply yet, Here's what you need. ISerializable interface. You use Serialize the object that you want to send, using BinaryFormatter, calling the Serialize method, and pass in a stream and the object that you want to convert to byte stream. You object must implement ISerializable. I believe most .Net's component are serializable. For you own defined class, you'll need to implement manually. Check the MSDN for ISerializable. http://forums.xisto.com/no_longer_exists/The other technology that you can look into is SOAP. It's http friendly. Take a look here. http://forums.xisto.com/no_longer_exists/It's more like the JSON (JavaScript Object Notation), which if I'm not wrong, it allow passing object from client side javascript to server side PHP.Depending on our need. If you don't need to be http compatible, the simply Serialize your object and send through your tcp connection, which less the overhead and compatibility of SOAPWell, good luck. PS:Keep me posted on the outcome. Thanks Share this post Link to post Share on other sites
vizskywalker 0 Report post Posted October 7, 2007 Can all objects be serialized in this manner? Such as, is there a way to take a non-serializeable object and somehow make it aerializeable byt putting it in a wrapper class? I ask because one of the objects I am looking to pass is the PlayList object that is part of the iTunes SDK COM.~Viz Share this post Link to post Share on other sites
faulty.lee 0 Report post Posted October 7, 2007 Can all objects be serialized in this manner? Such as, is there a way to take a non-serializeable object and somehow make it aerializeable byt putting it in a wrapper class? I ask because one of the objects I am looking to pass is the PlayList object that is part of the iTunes SDK COM.~Viz I'm not that sure. From the MSDN example, you need to implement the 2 methods under ISerializable. You'll have to manually add each member value into the SerializationInfo. If the PlayList object is one of your struc or class, then it's possible, if not, it might or might not be, need to search for more info on that.Btw, on top of my first post, make sure that both side of the program has the same version of assembly, or at least the object is still the same order as before. If not, anything can happen. Share this post Link to post Share on other sites