How do you read an incoming tcp stream until a specific delimiter is found in C#? The only possible solution I have come up with is reading the incoming stream one byte at a time.
Reading the TCP socket and scanning for a delimiter are two different things.
You can read all available data on a non-blocking socket, into a byte array/string, then scan the byte array for your delimiter. Do whatever else you need to do, including perhaps saving data after the delimiter for the next read attempt.
Its best to use some sort of buffer to add incoming data into so the socket operations don't exactly dictate handling of the data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With