Hello,
I have to replicate the following Java functionality in C++ to get data from Linux to Windows. Is Winsock2 the best way to go?.
Also, any reference code to suggest?
TIA, B
import java.nio.ByteBuffer; public class MessageXdr { private ByteBuffer buffer; private int size; // taille max corps de message private static final int T_MAX_CORPS_MSG = 16384; public MessageXdr() { buffer = ByteBuffer.allocate(4 * T_MAX_CORPS_MSG); size =0; } public MessageXdr(byte[] array) { ByteBuffer tmpBuffer = ByteBuffer.wrap(array); buffer = tmpBuffer.asReadOnlyBuffer(); size = array.length; } public int getSize() { return size; } public int getPosition() { return buffer.position(); } public byte[] getArray() { return buffer.array(); } public void resetBuffer() { size = 0; buffer.rewind(); } public int readInt() { int retour = buffer.getInt(); return retour; } public long readUnsignedInt() { ByteBuffer tmp = ByteBuffer.allocate(8); tmp.putInt(0); tmp.putInt(buffer.getInt()); return tmp.getLong(0); } public float readFloat() { float retour = buffer.getFloat(); return retour; } public void writeInt(int v) { buffer.putInt(v); size+=4; } public void writeFloat(float v) { buffer.putFloat(v); size+=4; } }