views:

836

answers:

3

i want to transfer an object or a data set from one computer and other i am sending strings using streamwriter and reader now i want send an object via this client connection so how do i send this object or a dataset using this connection ?

Consider i want to send a dataset now what you people suggest

+2  A: 

I think what you want is to use Remoting. This is a huge topic mind, so heres the place to start: http://msdn.microsoft.com/en-us/library/kwdt6w2k%28VS.71%29.aspx

Now, you can speed the process up of devloping an application to send/recieve data via TCP, and thats by using WCF and the netTcpBinding. This is the approach I would take nowadays as it's a lot simpler and quicker to develop, plus any knowledge gain can be reused to created various types of web services.

netTcpBinding: http://msdn.microsoft.com/en-us/library/ms731810.aspx

wcf site: http://msdn.microsoft.com/en-us/netframework/aa663324.aspx

Jaimal Chohan
+1  A: 

If you have control over both sender and receiver you could try serialization.

Basic implementation of serializing and deserializing

Josiah Peters
A: 

If the class definition for the object you want to send is accessible to both the client and server - say, defined in a common class library - you can serialize it to binary data, send it over the connection, and deserialize it. Serializable classes are pretty easy to get into and out of binary, XML and JSON formats.

See http://www.informit.com/guides/content.aspx?g=dotnet&seqNum=209

I haven't tried this with a dataset, but I don't foresee any problems. You may also consider serializing to XML if your application requires it - for instance, if you're communicating with a non-.net application on another platform.

Note: Josiah Peters' linked example code seems much cleaner than the link I referenced.

David Lively