Click here to Skip to main content
15,891,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
is it possible to send data from remote object to the server in C# remoting using TCP channel????



Please reply

thanking you in advance.
Posted
Updated 18-Oct-11 21:23pm
v2

Of course you could, I'm just not so sure about what you mean. There are many patterns that could be used in order to send and retrieve data properly and preserving its purpose, destination and even its structure.

The idea is simply, Lets say that you have a remote object.

C#
class RemoteObject
{
// ... //

public SerializableData getData() { // ... // }

// ... //
}


And also you have got the definition of SerializeableData, which is a simple class, with the attribute [Serializable] on top of it.

C#
/* Important Attribute - means that the declared object could be converted to and from a byte sequence by the .NET Serialization. */
[Serializable] 
class SerializableData
{
/* some data that you would like to send. */
}


All you gotta do next, is figure out how to use .NET's Serialization (which supplies methods object to byte[] and then byte[] to object), and you are good to go. You could read all about it: http://www.codeproject.com/KB/cs/objserial.aspx[^]. The example there is explaining how you could serialize an object into and out of a file, but you could similar methods, and implement writing and reading it from a network stream.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900