On Mon, 02 Feb 2009 04:32:10 -0800, Zalabado <zala@xxxxxx> wrote:
> Well, according to google :-), Serialization is the process of converting
> complex objects into stream of bytes for storage. Deserialization is its
> reverse process, that is unpacking stream of bytes to their original
> form.
>
> Therefore, i dont get it what the serialization has to do with
> convention of
> information encoding that is defined by me... It has everything to do with it. Socket i/o is strictly based on bytes.
You can only send bytes and you can only receive bytes. If you have some
other data structure to send and receive, you need to convert it to bytes,
and then convert it from bytes. Which, as you have already seen, is
exactly what serialization is about.
Now, there are other ways to go about it. You can define your own way to
package up the data, and that may well produce fewer bytes to send than
using the built-in serialization. But at some point you have to convert
the data to bytes so that it can be sent via the Socket, and then convert
the bytes back to your desired data structure.
Note that .NET includes a couple of features meant to abstract away from
the Socket class: remoting, and WCF. Unfortunately, I don't know a lot
about either so I can't really answer questions about them, but they
provide a way for your program to simply deal with objects and not worry
about the serialization part. Using either of those, you won't even use
the Socket class directly.
Pete