Hi,
i'm pretty a noob in .NET and try to serialize a class and send it into an UDP packet.
I use the udpClient class on my client and server sides and I can get an array of byte to transfert from one to another.
What I don't know is how to serialize my object (which basically consist of 3 strings and 1 dictionnary). that object has the name "myCustomClassInstance" in the following example code.
(-->this also means that its size is variable and that I will have to check that the size of my serialized object is under the [MTU minus header] size. but that's another problem.)
For the moment I get to serialize my message by using a binaryformater then send it:
but on the listining side, the udpClient.receive(myIPEndPoint) method returns a byte array.
Then, I don't get how to convert back that byte array in an instance of the same type of my "myCustomClassInstance" object.
Thanks for the help and advices.
i'm pretty a noob in .NET and try to serialize a class and send it into an UDP packet.
I use the udpClient class on my client and server sides and I can get an array of byte to transfert from one to another.
What I don't know is how to serialize my object (which basically consist of 3 strings and 1 dictionnary). that object has the name "myCustomClassInstance" in the following example code.
(-->this also means that its size is variable and that I will have to check that the size of my serialized object is under the [MTU minus header] size. but that's another problem.)
For the moment I get to serialize my message by using a binaryformater then send it:
Code:
Dim mySimpleFormatter As BinaryFormatter = New BinaryFormatter()
Dim myStream As New MemoryStream()
mySimpleFormatter.Serialize(myStream, myCustomClassInstance)
myUdpClient.Send(mystream, mystream.Length)
Then, I don't get how to convert back that byte array in an instance of the same type of my "myCustomClassInstance" object.
Thanks for the help and advices.