G
Gator
Hi All,
Basically my situation is this, I have a server implemented in C++,
unmanaged code, using proprietery protocol over TCP/IP to communicate
with the cilent(c++ also).
Now, I am implementing the another client in C#. Server side can not
be
changed![Frown :( :(](/styles/default/custom/smilies/frown.gif)
So, I am using tcp/ip sockets. In the end I get byte[] on the client
side, which originally was some C++ class object, converted to byte
array.
What is the most efficient way to convert that byte array to C#
object?
I've checked few sources, writing custom serializer doesn't seem to be
a good idea, as the serialize will receive a stream object, which only
has byte read.
So far the best I've come up with is to create BinaryReader based on
the NetworkStream which in turn is created from the socket. More or
less works, but string reading is a hassle, because the server won't
send it in the format needed by BinaryReader, and I have to create 2
additional objects.
Is there anything that can operate on byte[] to read simple types from
it based on the offset and length? I.e. interpret bytes as a type?
Basically my situation is this, I have a server implemented in C++,
unmanaged code, using proprietery protocol over TCP/IP to communicate
with the cilent(c++ also).
Now, I am implementing the another client in C#. Server side can not
be
changed
![Frown :( :(](/styles/default/custom/smilies/frown.gif)
So, I am using tcp/ip sockets. In the end I get byte[] on the client
side, which originally was some C++ class object, converted to byte
array.
What is the most efficient way to convert that byte array to C#
object?
I've checked few sources, writing custom serializer doesn't seem to be
a good idea, as the serialize will receive a stream object, which only
has byte read.
So far the best I've come up with is to create BinaryReader based on
the NetworkStream which in turn is created from the socket. More or
less works, but string reading is a hassle, because the server won't
send it in the format needed by BinaryReader, and I have to create 2
additional objects.
Is there anything that can operate on byte[] to read simple types from
it based on the offset and length? I.e. interpret bytes as a type?