Reputation: 966
everybody. I've got very simple and not once repeated question :) The main idea is: I have to send object of class/structure described by me via TCP/IP using C#. I've been succeed using TCPListener and TCPClient classes and was able to send messages (strings). But after I start to practice with serialization and etc. my successful experience ends. I've read a lot of stuff before writing here, really, even something about marshalling option and other strange stuff, but i don't understand it, and i think it's not needed. So, what I ask from U guys, it would be so pleasure, if U give me an example.
Class example:
[SERIALIZABLE]
public class SomeClass
{
public SomeClass(){}
private int SomeIntData;
private Int32 SomeInt32Data;
private Double SomeDoubleData;
}
Please, show me how to send object of this class SomeClass via tcp/ip. Thanks.
Upvotes: 0
Views: 1607
Reputation: 39013
Add a [Serializable]
attribute to it, and then format it using a BinaryFormatter
Use Serialize
to serialize the object into a stream, and Deserialize
to create it on the other side.
Upvotes: 3