unsigned short in network byte order
Posted on 2004-09-15
I need to two byte message length indicator at the beginning of a message I'm sending to a server. The message length will be an unsigned short in network byte order.
The following is how I plan on doing it:
snprintf(pBuffer, sizeofbuffer, "%u", htons(sizeof(ReqMsgTemp)));
RegMsgTemp is the message I'm sending to the server. pBuffer will be prepended to ReqMsgTemp.
Is this the right way of doing it?