Login  
Search All Forums
Dart Home | PowerTCP Telnet for .NET | Custom Development Reply | PowerTCP Telnet for .NET Topics | Forums   
AuthorForum: PowerTCP Telnet for .NET
Topic: Telnet read question
coolandy2012

From: Bolton, United Kingdom
Posts: 28
Member Since: 04/04/11
posted May 17, 2011 12:33 PM

When I use the function Telnet.Read() as follows:

byte[] buffer = new byte[1024];
teln.Read(buffer, 0, 1024);
receive = System.Text.Encoding.ASCII.GetString(buffer);

At what point does it stop reading and place the buffer into the string receive as above? Does read up to some kind of terminator like a null?
Nick B (Admin)

From: Utica, NY USA
Posts: 619
Member Since: 05/25/10

Extra Support Options
Custom Application Development

posted May 17, 2011 1:14 PM

Hello,

The read method will block until data is available on the socket, then will read all available data off of the socket or until the specified count, or until the buffer is full, then return. If the count of available data is less than the specified count, the method will return when all available data is read. If you would like it to read until a delimiter/terminator, use the ReadToDelimiter method.
coolandy2012

From: Bolton, United Kingdom
Posts: 28
Member Since: 04/04/11
posted May 18, 2011 6:04 AM

Ok thanks for the information.

If I was to use the Telnet.ReadToDelimiter Method. How would I convert it to a readable string?

Data data
data = Telnet.ReadToDelimiter("\n");
string receive = ????;

In my last post I converted the buffer (byte array) to a string. The ReadToDelimiter only takes 1 parameter, so I am unsure how to go about converting the data into a readable string.
Nick B (Admin)

From: Utica, NY USA
Posts: 619
Member Since: 05/25/10

Extra Support Options
Custom Application Development

posted May 18, 2011 8:44 AM

Data.ToString() is a System.Buffer decoded into a string using the Encoding property. You may also access the buffer directly via Data.Buffer.
Reply | PowerTCP Telnet for .NET Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX