
Converting different data types from a socket.
I am trying to convert the bytes receive from a CAsyncSocket. The data
I am receiving will always be in a standard message format. the first 8
bytes of data are a header, followed by data.
My question is: how do I convert the bytes received into UINT, char...
etc.
I know that the first 4 bytes make up a UINT. and the second 4 bytes
make up UINT. the remaining 5 bytes are char...
the raw data looks like this:
0.0.0.16.0.0.1.1.97.98.99.100.101
should be
| 16 | 255 | a | b | c | d | e |
how do I extract the first and second 4 bytes into UINT?
OnReceive()
{
BYTE *pBuf = new BYTE[1025];
int iBufSize = 1024;
int iRcvd = 0;
iRcvd = MySocket.Receive(pBuf, 1024);
---->> now.. that the data is stored in pBuf, how do I use the first
4 bytes to = UINT?
the char part is easy.
char cdata[0] = pBuf[8]; etc.
Quote:
}
any help would be appreciated.