Sending BYTE* over socket

2019-07-30 22:56发布

问题:

I'm trying to send a BYTE* over a socket, but the send function only allows me to send a char* buffer. Is this possible? How would I go about casting it back on the other side?

回答1:

Use reinterpret_cast to cast from BYTE* to char*. A BYTE is an unsigned char typedef, so you shouldn't have any issues.

char* foo = reinterpret_cast<char*>(bar);

Where bar is your BYTE*.