I'm sending messages over TCP/IP, I need to prefix message length in a char array and then send it. How do I do it?

Also can you please provide an example of how to extract it at the another end. And if possible, please explain.

I'm using C++ and Winsock.