Hi,
I want to you readline on a tcpip data stream but the data is terminated with a 0 1, not a /n, is there a way to change the behaviour of the readline function or must I write my own binary based reader?

thanks
Robert Craven

Recommended Answers

All 2 Replies

I don't think you can change ReadLine to do that. You can use Peek, Read, and a StringBuilder though.

Dim buffer As New StringBuilder

Do While sr.Peek() <> 0
  buffer.Append( Convert.ToChar( sr.Read() ) )
Loop

Thanks, I appreciate the response and will implement it. I was appalled to see that my original post said "Iwant to you" instead of "I want to use" and further appalled that I can't edit it, but alas, I guess that is the world of technical threads, it would be cheating to change them after the fact.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.