For example, I have binary message format like this: 1. It has a four-bytes header and payload. 2. The four-bytes header is the payload size of the message. First I want to set the size of the recv buffer to 4. After the four bytes arrived, I parse them and get the size of the payload. Then I set the size of the recv buffer to the size of the payload to recv the payload.