-1

I have this java code :

    ByteBuffer p = ByteBuffer.allocate(packet.length - 10 + 14);
    p.order(ByteOrder.LITTLE_ENDIAN);
    p.putInt(packet.length);
    p.putInt(packet.request_id);
    p.putInt(packet.type);
    p.put(packet.paylod);
    p.put((byte) 0);
    p.put((byte) 0);
    new DataOutputStream(sock.getOutputStream()).write(p.array());

And i want to translate it to VB .NET I started with this :

    Dim p(packet.length - 10 + 14) As Byte
    Dim Stream As MemoryStream = New MemoryStream()
    Dim Writer As BinaryWriter = New BinaryWriter(Stream)
    Using Writer
        Writer.Write(packet.length)
        Writer.Write(packet.request_id)
        Writer.Write(packet.type)
        Writer.Write(packet.paylod)
        Writer.Write(CByte(0))
        Writer.Write(CByte(0))
    End Using
    p = Stream.ToArray()

But after i dont know how to sort in little endian order

1 Answers1

0

Looking through the documentation, http://msdn.microsoft.com/en-us/library/24e33k1w.aspx, it seems like the BinaryWriter.Write methods for integers default to little endian order.

BinaryWriter stores this data type in little endian format.

So it should work the way it is.

Kratz
  • 4,280
  • 3
  • 32
  • 55