implement buffer for reading socket.
parse message with buffer.