Sending data

Top  Previous  Next

The classes provided in Telnet Factory for .NET offer asynchronous communications with the telnet server. This allows you to send data to the server while a separate thread runs in the background reading data from the server.

 

As data is read from the telnet server it is classified as either option data or screen data. The type of data read will determine how you send data back to the telnet server.

 

 

Option Data

 

Option data represents an option command sent by the telnet server. Upon reading an option command the appropriate option event is fired. It is the responsibility of your code to capture this event and send an option command response back to the telnet server.

 

 

Screen Data

 

Screen data represents data that is displayed on the terminal screen. Examples of screen data include the login prompt displayed asking for a username, and the shell prompt displayed after a command has been executed on the remote telnet server. As each character of screen data is read from the telnet server the DataReceivedEvent is fired. It is the responsibility of your code to capture this event.

 

At certain points during your telnet session the server will stop sending data and will prompt you for information to send to the telnet server. These prompts let you know that the server has stopped sending data and more importantly is ready to receive some data.

 

One such prompt is the login prompt that is displayed when trying to access a server using the telnet protocol.

 

Example

 

[C#]

login:

 

This prompt is an indicator that the telnet server is waiting to receive data. The TelnetOutputStream class provides methods for sending data to the telnet server.

 

If you are using the Telnet class then you can access it's TelnetOutputStream via the Output property. Using the TelnetOutputStream you can then send data using the PrintLn method.

 

Example

 

[C#]

TelnetOutputStream Output = Telnet.GetOutputStream();

Output.PrintLn("jsmith");

 

 

[Visual Basic]

Dim Output As TelnetOutputStream

Output = myTelnet.GetOutputStream

output.PrintLn("jsmith")

 

 

The above example obtains the output stream from the Telnet instance, casts it to a TelnetOutputStream and sends the string "jsmith" to the telnet server.

 

Note

 

The TelnetOutputStream.PrintLn method automatically appends a carriage-return and line-feed (CRLF) to the end of the data sent. The CRLF is appended to let the telnet server know that the client has finished sending data and is ready to receive data. If you do not want to append a CRLF then you may send raw data using the TelnetOutputStream.Write method.

 

 

If you are using the TelnetSession class then you can send data by invoking the TelnetSession.Send method.

 

Example

 

[C#]

TelnetSession session = new TelnetSession(hostname);

...

session.Send("jsmith");

 

 

[Visual Basic]

Dim mySession As TelnetSession

...

mySession.Send("jsmith")

 

 

See Also

 

Receiving Data

 





Home | Company | Products | Solutions | Purchase | Support | Services | Blog

© 2021 JSCAPE LLC