I am writing a client for a server that usually sends data as strings of 500 or less bytes. However, data will sometimes exceed this, and one data set can contain 200,000 bytes, as all clients know (during initialization or significant events). However, I would not want each client to work with a 50 MB socket buffer (if possible).
Each data set is separated by a null character \0. What structure should I look for to store partially sent datasets?
For example, a server might send ABCDEFGHIJKLMNOPQRSTUV\0WXYZ\0123!\0. I would like to handle ABCDEFGHIJKLMNOPQRSTUV, WXYZand 123!whatever. In addition, the server can send ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890LOL123HAHATHISISREALLYLONGwithout a trailing character. I would like this dataset to be stored somewhere for later addition and processing.
In addition, I use the techniques of asynchronous socket ( BeginSend, EndSend, BeginReceive, EndReceive), if that matters.
I am currently discussing between List<Byte>and StringBuilder. Any comparison of the two for this situation would be very helpful.
source
share