Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Passing Objects Over A Network
vizskywalker
post Oct 7 2007, 08:05 PM
Post #1


Techno-Necromancer
Group Icon

Group: Members
Posts: 1,018
Joined: 13-January 05
From: The Net
Member No.: 2,127



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 cool.gif how to do that. Any ideas are helpful.

Thanks,
~Viz
Go to the top of the page
 
+Quote Post
faulty.lee
post Oct 7 2007, 09:20 PM
Post #2


Premium Member
Group Icon

Group: [HOSTED]
Posts: 495
Joined: 5-November 06
Member No.: 17,016



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, tongue.gif

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://msdn2.microsoft.com/en-us/library/s...objectdata.aspx

The other technology that you can look into is SOAP. It's http friendly. Take a look here. http://www.codeproject.com/soap/XMLFormatter.asp
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 SOAP

Well, good luck.

PS:Keep me posted on the outcome. Thanks
Go to the top of the page
 
+Quote Post
vizskywalker
post Oct 7 2007, 10:18 PM
Post #3


Techno-Necromancer
Group Icon

Group: Members
Posts: 1,018
Joined: 13-January 05
From: The Net
Member No.: 2,127



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
Go to the top of the page
 
+Quote Post
faulty.lee
post Oct 7 2007, 10:28 PM
Post #4


Premium Member
Group Icon

Group: [HOSTED]
Posts: 495
Joined: 5-November 06
Member No.: 17,016



QUOTE(vizskywalker @ Oct 8 2007, 06:18 AM) *
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.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Network Places: Alternative To Ftp On Windows(10)
  2. Dialup On Wireless Network(18)
  3. Kde Starting Problem(4)
  4. Switch Network Settings With Batch Files(18)
  5. Problem: Network Connection Fails Every 2 Mins(12)
  6. How To Connect Computers In A Wi-fi Network(10)
  7. Unable To Connect My Comp. To A Wireless Network(5)
  8. Listening To Music Over A Home Network(16)
  9. Smf Theme Creation Help(13)
  10. Suse 10.0: Can't Get On Network! Help Please!(11)
  11. Programming In Glut (lesson 3)(1)
  12. Programming In Glut (lesson 4)(7)
  13. Baylan Network Switch Problem(1)
  14. C++: Basic Classes(5)
  15. Wireless Network Not Connecting(6)
  1. Won't Reconnect To Wireless Network Automatically Once Disconnected(7)
  2. How To Keep The Internet Out From A Network ?(9)
  3. Networking With A Wireless Network Adapter(10)
  4. Proxy And Network Drive Script(2)
  5. Linking Iframes(1)
  6. Extending A Wireless Network(2)
  7. Are You Compliant With The Network Etiquette ?(3)
  8. Bonding Network Interfaces For Double Speed?(0)
  9. Network Outage. Distribution Switch Ddosed.(5)
  10. School / Uni Network And Internet Restriction(11)
  11. Tracing Broadcast Storms(1)
  12. Getting My Wireless Network Adapter Working On Linux(2)
  13. Optimum Network Solution(2)


 



- Lo-Fi Version Time is now: 11th October 2008 - 09:13 AM