Re: garbled long value returned from the network
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Sat, 18 Feb 2006 07:03:02 -0000
<family.sens@xxxxxxxxx> wrote:
im using a C# webservice to communicate some data over a socket to a
VC++ program.
what the vc++ program does is return a struct() over the socket.
now the struct contains 2 32 bit integers (according to VC++) i.e. long
(System.Int32)
Note that a long may be 32 bits in C (in some compilers anyway) but in
C# an int is 32 bits and a long is 64.
all the byte[] data is received correctly, however , if im expecting
'320' as the value of the long variable im getting a huge number like
'612334539'.
does this have something to do with Little-Endian / Big-Endian issues ?
Sounds like it.
does this require me to use IPAddress.NetworkToHostOrder() ?
No. You can use my EndianBitConverter, available at
http://www.pobox.com/~skeet/csharp/miscutil
That lets you convert in either endianness. (There's an equivalent
EndianBinaryReader/Writer, too.)
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.
- Follow-Ups:
- Re: garbled long value returned from the network
- From: family . sens
- Re: garbled long value returned from the network
- From: family . sens
- Re: garbled long value returned from the network
- References:
- garbled long value returned from the network
- From: family . sens
- garbled long value returned from the network
- Prev by Date: Re: How does combobox know key/value?
- Next by Date: Re: Missing characters after file rewrite using File.OpenText
- Previous by thread: garbled long value returned from the network
- Next by thread: Re: garbled long value returned from the network
- Index(es):