I was hoping for some advice on my little problem as i'm a little stumped.
I writing what is basically a telnet client using sockets in vb.net. The client works fine until I want to start parsing the received text for ANSI escape sequences(the ones that give colour). The problem seems to mainly lie with the received buffer size.
Currently I have set the buffer to 1024, the problem being that even if the data received from the server isnt 1024 the string still is that length, heres the parsing loop:
' rf is the received buffer string.
do until pos=len(rf)
If Strings.Mid(rf,pos,1) = chr(27) ' this is the start of an ansi escape
do until Strings.right(rf,1) = "m" ' m is the end of the sequence
escapecode = Strings.mid(rf,pos,i)
' here we should be changing the colour of the richtextbox
elseif Strings.mid(rf,pos,1) = chr(10)
' this is here to cut out line feeds as the richtextbox only needs carraige returns
richtextbox1.text = richtextbox1.text & strings.mid(rf,pos,1)
Basically although it works it runs very bloody slowly, 1 reason I think is because even if you only receive 10 bytes from the server the length of the received buffer is still 1024 so my code has to loop round the entire thing all the time.
To clarify i'm using the getstream method on a separate thread to pass information to this sub.
In order for my project to be viable this needs to work very fast as I will also need to compare received text to an array of strings for doing auto commands(triggers).
Thanks in advance for any suggestions you chaps can offer