Welcome to the PowerTCP Emulation for .NET Documentation

PowerTCP Emulation for .NET

PowerTCP Emulation for .NET Documentation

Build terminal emulation capabilities into your Windows application or enable your ASP.NET Web application to communicate with backend UNIX servers for screen scraping. Features include screen scraping, graphic characters, scroll-back buffer, and superior printing capabilities. Built-in support for Key mapping makes configuration simple, plus built in Telnet capability makes connectivity as easy as a single line of code. Includes a custom VT font and support for VT320, VT220, VT100, VT52.

In PowerTCP Emulation for .NET Documentation.

Getting Started
Provides an overview of PowerTCP Emulation for .NET and discusses such topics as distribution, licensing, and support.
Using PowerTCP in VS.NET
Provides step-by-step instructions for creating a project using VS.NET, integrating PowerTCP Emulation for .NET, and creating a simple application.
Using the Vt Control
Discusses how to use the Vt component to display data.
Using Events in PowerTCP
Discusses how to use the events provided by PowerTCP Emulation for .NET.
Reference
Provides a language/syntax reference for PowerTCP Emulation for .NET.
Samples
Describes the samples that are installed with PowerTCP Emulation for .NET.

Send comments on this topic.

© 2003 Dart Communications. All rights reserved.


Getting Started

PowerTCP Emulation for .NET is a complete suite of controls, components, and classes that enable the integration of terminal emulation with Telnet and remote access (REXEC, RSH, RLOGIN) communications into any .NET application. This topic, and related subtopics, address issues such as licensing, distribution, and support for PowerTCP Emulation for .NET. To find a tutorial or walkthrough pertaining to usage of PowerTCP Emulation for .NET, see Documentation Map. For a programmer's reference of the classes used by the PowerTCP Emulation for .NET, see Reference topic.

In This Section

Documentation Map
Provides a good navigational aid to quickly find the topic you want.
Requirements
Discusses the requirements needed to use PowerTCP Emulation for .NET.
License Installation
Provides step-by-step instructions on installing a license.
Trial Operation
Provides an overview on using PowerTCP Emulation for .NET in trial mode.
Deployment in ASP.NET
Discusses the extra steps that are required to distribute an application in ASP.NET.
Support
Provides an overview of the support options that are available for this product.
Key Mapping Overview
Provides a brief introduction to VT keymapping.

Related Sections

Using PowerTCP within Visual Studio .NET
Demonstrates how to create a project and add a PowerTCP component.
Using the Vt Control
Discusses how to use the Vt component to display data.
Using Events in PowerTCP
Discusses how to use the events provided by PowerTCP Emulation for .NET.
Reference
Provides a language/syntax reference for PowerTCP Emulation for .NET.
Samples
Describes the samples that are installed with PowerTCP Emulation for .NET.

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2003 Dart Communications. All rights reserved.


PowerTCP Emulation for .NET Documentation Map

The following topics were designed to get you quickly developing using PowerTCP Emulation for .NET

To | See
Learn how to create a project in Visual Studio .NET. | Creating a Project
Learn how to add a control to a form. | Creating an Instance of a Control Using Visual Studio .NET
Learn how to add a control to a project as a reference. | Adding a Control as a Reference within Visual Studio .NET
Learn how to build an emulator application. | Building an Emulator (Internal Telnet)
Learn how to build a scripted (blocking) emulator application. | Building a Scripted Emulator (External Telnet)
Learn how to screen scrape the Vt control. | Screen Scraping
Learn how to keymap with the Vt control. | Using Keymapping with the Vt control
Learn how to resize the Vt control. | Resizing the Vt control
Learn about the font implementation with the Vt control. | About Fonts

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2003 Dart Communications. All rights reserved.


Requirements

In order to use PowerTCP Emulation for .NET you must have the following:

  • Microsoft Visual Studio .NET 2003 (Recommended)
  • .NET Framework 1.1.

Please note that the PowerTCP Emulation for .NET does not support the .NET Framework 1.0.

You can download the .NET Framework at http://msdn.microsoft.com/library/default.asp?url=/downloads/list/netdevframework.asp.

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2003 Dart Communications. All rights reserved.


License Installation

Your PowerTCP License Agreement provides you with a single-seat development license and the right to distribute PowerTCP objects with NO ROYALTIES of any kind. Some PowerTCP objects are marked as licensed. This topic covers:
  • Trial Installation
  • Installing a Fully Licensed PowerTCP Product
  • Re-installing a PowerTCP Product
  • License Details

Trial Installation

Installing a PowerTCP product as a fully–functional trial involves running the setup program (available from www.dart.com) without completing the License Registration process. The trial will operate for 30 days after installation. Proceed to step 2 of Installing a Fully Licensed PowerTCP Product when you are ready to license the product.

See Trial Operation for more information.

Installing a Fully Licensed PowerTCP Product

Once you have downloaded the latest version, complete the following steps to register your PowerTCP product:

  1. From the Start menu, select Programs, select PowerTCP, select the PowerTCP product you downloaded, and then click Registration.
  2. In the PowerTCP Registration dialog box, click Register.
  3. Enter your Serial Number, First Name, Last Name, and Organization information.
  4. Click Next.
  5. Enter your Email Address, Purchased From, and Purchase Date information.
  6. Click Next.
  7. Verify that the information is correct, and then click Next.
  8. When the registration process is complete, click Exit. (Note: Clicking Done at this step displays your currently registered PowerTCP product. Click Exit to complete the registration process and close the dialog box.)
If you do not have Internet Access on your development machine, please follow these instructions:
  1. From the Start menu, select Programs, select PowerTCP, select the PowerTCP product you downloaded, and then click Registration.
  2. In the PowerTCP Registration dialog box, click Edit.
  3. Enter your serial number in the Serial # field.
  4. Write down the number in the Key field.
  5. On a machine that has Internet access, log on to the Dart registration page (http://www.dart.com/register/).
  6. Enter all required information. Required information is bolded. The Key is the number you wrote down in Step 4.
  7. Click Submit. A seven-digit registration code should appear.
  8. On your machine (the machine on which you completed Steps 1-4), if necessary, access the PowerTCP Registration dialog box to display the Currently Registered Products area containing the Key number.
  9. Enter your serial number and the seven-digit registration number you obtained in Step 6.
  10. Click Add.
  11. Click Exit.

After either of the two registration procedures are complete, your PowerTCP product appears in the Registered Tools field at the top of the registration form. Make sure you recompile your application after you register the PowerTCP product.

If you do not register your PowerTCP product at this point, it will operate as a trial.

Re-installing a PowerTCP Product

The Key provided by the Registration Program is derived from a system number that is changed when the C: drive is reformatted. If you reformat your hard disk and need to re-install your PowerTCP product, follow the steps in Installing a Fully Licensed PowerTCP Product. A new Registration Number will be generated.

License Details

When you insert a PowerTCP component into a project, most development environments verify that the control is licensed for development. The component will work if you correctly entered the PowerTCP product Serial Number. See Installing a Fully Licensed PowerTCP Product for more information. When you compile your application, the development environment requests this Serial Number and embeds it in the application. When users run your application, the application submits this Serial Number to the control and the Serial Number is checked for validity. If the Serial Number is correct, then the application runs. This verification process occurs automatically.

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2003 Dart Communications. All rights reserved.


Trial Operation

If you install a PowerTCP product without registering a Serial Number, it operates as a fully–functional trial for up to 30 days. If you need more time to evaluate the product, contact the Sales Department at sales@dart.com.

Trial Notification in Development Mode

Trial notification does not occur during design-time.

Trial Notification During Run-Time

PowerTCP products request a Serial Number when you compile your application. A dialog box appears warning you that the component is not licensed for deployment. Do not distribute your application using a trial product—the component will not work after the trial period! However, you may test your application during your trial period. No trial notification dialog is shown so as to not interfere with an IIS application test. Please be aware that the component will cease to function after the trial period has expired.

See License Installation for more information on product registration.

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2003 Dart Communications. All rights reserved.


Deployment In ASP.NET

To deploy a licensed ASP.NET Web Application or Web Service, follow these steps.

  1. Compile the ASP.NET application on a licensed development machine.
  2. If you are instantiating the component dynamically, be sure to include a licenses.licx file (see the Creating the Licenses.licx File topic for more information.
  3. Copy the contents of the bin folder and the ASP.NET source files (such as .aspx files) to the server that will be hosting the application.
  4. Create a virtual directory pointing to the folder containing the Web Application or Web Service.

Note: It is not necessary for the deployment server to be licensed or to contain a copy of a license in its registry.

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2003 Dart Communications. All rights reserved.


Support Options

Our mission at Dart is to deliver high quality Internet connectivity solutions to Internet application developers. Our goal is to supplement these solutions with timely support resources that can help at many different levels.

Related Links (you have an active connection to the Internet to view these links).

Paid Support Options
Discusses the paid support options available covering everything from single incidences to extensive subscriptions.
Free Support Options
Provides access to free materials to help your development, including FAQS, online help files, tutorials, code snippets, online asp samples, and a free support forum.
Support Forum
Provides access to our support forum, monitored by our own development staff as time permits.
Dart Solutions
Discusses the custom development support offered by Dart Solutions.

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2003 Dart Communications. All rights reserved.


Key Mapping Overview

The Vt component uses a default key mapping that is close to the keyboard layout of a VT terminal. For example, the PF1 key on the VT is the top left key on the numeric keypad, so the NUMLOCK key on the PC numeric keypad is mapped to the PF1 function key. The following table summarizes the default keyboard mappings:

VT Key | PC Key
Find | INSERT
InsertHere | HOME
Remove | PAGE UP
Select | DELETE
PrevScreen | END
NextScreen | PAGE DOWN
PF1 | NUMLOCK
PF2 | / (on numeric keypad)
PF3 | · (on numeric keypad)
PF4 | - (on numeric keypad)
, (comma) | + (on numeric keypad)
- (minus) | + (on numeric keypad)
Enter | ENTER (on numeric keypad)
F6–F10 (w/ Shift for user-defined keys) | F6 through F10 (w/ CTRL for user-defined keys)
F11–F20 (w/ Shift for user-defined keys) | SHIFT+F through Shift+F10 (w/ CTRL for user-defined keys)
Help | F11
Do | F12

To modify these default mappings, set the KeyCode parameter of the KeyDown event to 0 (canceling out the default string normally generated by the key); users can then send any arbitrary string directly out the communications channel. When F1 is pressed, for example, users may substitute the "SS3 P" sequence.

Detailed VT Character String Tables

The following tables are provided as a guide to the character strings generated by the VT. The reader may wish to obtain more complete programming information directly from Digital Equipment Corporation.

Control Sequence | 7-bit Mode | 8-bit Mode
CSI | ESC [ | 0x9b
SS3 | ESC O | 0x8f

VT/IBM Main Keypad Function Keys | Code Transmitted
BACKSPACE | DEL character
TAB | HT character
RETURN | CR or CRLF depending upon the NewLine property
CTRL, Lock, SHIFT | Does not send a code
SPACEBAR | SP character

VT Edit Key | IBM Edit Key | VT 220/320 Code | VT 100/52 Code
Find | INSERT | CSI 1 ~ | None
Insert Here | HOME | CSI 2 ~ | None
Remove | PAGE UP | CSI 3 ~ | None
Select | DELETE | CSI 4 ~ | None
Prev Screen | END | CSI 5 ~ | None
Next Screen | PAGE DOWN | CSI 6 ~ | None

VT/IBM Cursor Keys | VT100/220/320 Code Normal Cursor Key Mode | VT100/220/320 Code Application Cursor Key Mode | VT52 Code Normal Cursor Key Mode | VT52 Code Application Cursor Key Mode
UP ARROW | CSI A | SS3 A | ESC A | ESC A
DOWN ARROW | CSI B | SS3 B | ESC B | ESC B
RIGHT ARROW | CSI C | SS3 C | ESC C | ESC C
LEFT ARROW | CSI D | SS3 D | ESC D | ESC D

VT Aux Keypad | IBM Aux KeyPad | VT100/220/ 320 Code Numeric Keypad Mode | VT100/220/ 320 Code Application Keypad Mode | VT52 Code Numeric Keypad Mode | VT52 Code Application Keypad Mode
0 | 0 | 0 | SS3 p | 0 | ESC ? p
 |  |  | SS3 q |  | ESC ? q
 | 2 | 2 | SS3 r | 2 | ESC ? r
 | 3 | 3 | SS3 s | 3 | ESC ? s
 | 4 | 4 | SS3 t | 4 | ESC ? t
 | 5 | 5 | SS3 u | 5 | ESC ? u
 | 6 | 6 | SS3 v | 6 | ESC ? v
 | 7 | 7 | SS3 w | 7 | ESC ? w
 | 8 | 8 | SS3 x | 8 | ESC ? x
 | 9 | 9 | SS3 y | 9 | ESC ? y
- | Ctrl + "+" | - (minus) | SS3 m | - | ESC ? m
, | + | , (comma) | SS3 l | , | ESC ? l
. | . | . (period) | SS3 n | . | ESC ? n
Enter | Enter | CR or CR/LF | SS3 M | CR or CR/LF | ESC ? M
PF1 | NumLock | SS3 P | SS3 P | ESC P | ESC P
PF2 | / | SS3 Q | SS3 Q | ESC Q | ESC Q
PF3 |  | SS3 R | SS3 R | ESC R | ESC R
PF24 | - | SS3 S | SS3 S | ESC S | ESC S

VT Function Keys | IBM Function Keys | VT220/320 Code | VT100/52 Code
Hold Screen | F1 | (none) | (none)
Print Screen | F2 | (none) | (none)
Set-up | F3 | (none) | (none)
Data/Talk | F4 | (none) | (none)
Break | F5 | (none) | (none)
F6 | F6 | CSI 1 7 ~ | (none)
F7 | F7 | CSI 1 8 ~ | (none)
F8 | F8 | CSI 1 9 ~ | (none)
F9 | F9 | CSI 2 0 ~ | (none)
F10 | F10 | CSI 2 1 ~ | (none)
F11 (ESC) | <shift> F1 | CSI 2 3 ~ | ESC
F12 (BS) | <shift> F2 | CSI 2 4 ~ | BS
F13 (LF) | <shift> F3 | CSI 2 5 ~ | LF
F14 | <shift> F4 | CSI 2 6 ~ | (none)
Help | F11 | CSI 2 8 ~ | (none)
Do | F12 | CSI 2 9 ~ | (none)
F17 | <shift> F7 | CSI 3 1 ~ | (none)
F18 | <shift> F8 | CSI 3 2 ~ | (none)
F19 | <shift> F9 | CSI 3 3 ~ | (none)
F20 | <shift> F10 | CSI 3 4 ~ | (none)

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2003 Dart Communications. All rights reserved.


Using PowerTCP within Visual Studio .NET 2003

PowerTCP Emulation for .NET is a complete suite of classes which enable the integration of terminal emulation with TELNET and other remote access protocols like RSH (remote shell), REXEC (remote execute) and RLOGIN (remote login) into any .NET application. This topic and associated subtopics are mostly prerequisite to the usage of PowerTCP Emulation for .NET. For example, this topic illustrates such things as basic usage within Visual Studio.NET and how to add components as a reference. If you are already familiar with these tasks, you may benefit more by examining other topics.

In This Section

Creating a Project
This topic demonstrates how to create a new Windows project in Visual Studio .NET 2003.
Creating an Instance of a Control within Visual Studio .NET 2003
This topic demonstrates how to create and use a control using Visual Studio .NET 2003.
Adding a Control as a Reference
This topic demonstrates how to add a component as a reference using Visual Studio .NET 2003.
Creating the Licenses.licx File
This topic demonstrates how to create the licenses.licx file. This is only necessary when adding the component as a reference.
Using a PowerTCP Control in Your Own Custom DLL
Discusses the steps required when creating a dll that uses a PowerTCP control.
Synchronous Vs Asynchronous Use
This topic discusses the benefits and uses for synchronous and asynchronous methods.

Related Sections

Getting Started
Provides an overview of PowerTCP Emulation for .NET and discusses such topics as distribution, licensing, and support.
Using the Vt Control
Discusses how to use the Vt component to display data.
Using Events in PowerTCP
Discusses how to use the events provided by PowerTCP Emulation for .NET.
Reference
Provides a language/syntax reference for PowerTCP Emulation for .NET.
Samples
Describes the samples that are installed with PowerTCP Emulation for .NET.

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2003 Dart Communications. All rights reserved.


Creating a Project

The following steps provide a walkthrough to create a project in Visual Studio.NET 2003.

To create a project in Visual Studio .NET 2003, use the following steps:

  1. Start Visual Studio .NET 2003.
  2. From the File menu, choose New, and then choose Project.
  3. From the resulting dialog box, choose either Visual C# Projects or Visual Basic Projects and then choose Windows Application. Alternatively, if you wish to create an ASP.NET web application, you can choose ASP.NET Web Application. Specify a name and a location for the project, and then click OK.

  4. After these steps have been completed, the project is created.

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2003 Dart Communications. All rights reserved.


Creating an Instance of a Component Using Visual Studio .NET 2003

To create a component within Visual Studio .NET 2003, use the following steps (the following steps demonstrate using the Vt control):

  1. Create a project as described in Creating a Project .
  2. Add the Vt control to the form. To do this, right-click on the ToolBox and choose Customize ToolBox. If the ToolBox is not visible, navigate to the View menu and choose ToolBox.

  3. From the resulting dialog box, choose the .NET Framework Components tab, then scroll until you find the Vt and FontDialog controls (see the screen shot below). Check the checkbox next to it and select OK.

  4. Click the Vt control icon on the ToolBox, and "drag" an instance of it onto the form. The Visual Studio .NET environment will automatically create and instantiate an instance of the Vt control within your code and on the form. You can then expand the size of the control to meet your needs
  5. Make a quick application to test. Drag a button onto the form.
  6. Add the following code to the button "on-click" event handler.
    [C#]
// Connect to a server
vt1.Telnet.Connect("myservername");

[Visual Basic]
' Connect to a server
vt1.Telnet.Connect("myservername")
  7. Navigate to the Debug menu and choose Start. The app will compile and execute. You should now see the login screen for your server in the Vt control.

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Adding a Component as a Reference within Visual Studio .NET 2003

When using Visual Studio .NET 2003, the components included in PowerTCP Emulation for .NET can either be used as a component (see Using PowerTCP within Visual Studio .NET 2003 for more information) or added as a reference. If you are using one of the components as a reference, there are a few extra steps you must take, namely:

  • You must instantiate your own event handlers.
  • You must add a licenses.licx file to the project. (See Creating the Licenses.licx File for more information).

The following steps illustrate how to add a component as a reference within Visual Studio .NET 2003

To add a component as a reference within Visual Studio .NET 2003, use the following steps (the following steps demonstrate adding the Vt control):

  1. Create a project as described in Creating a Project.
  2. Add the Vt control and Telnet component as a reference. To do this right-click the References folder in the Solution Explorer and choose Add Reference (see the screen shot below). If the Solution Explorer is not visible, navigate to the View menu and choose Solution Explorer.

  3. You must add a licenses.licx file to the project. (See Creating the Licenses.licx File for more information).
  4. Make a quick application to test. Drag a button onto the form.
  5. Create an instance of the Vt control and the Telnet component within the button "on-click" event handler. (Don’t forget to add the namespaces for Dart.PowerTCP.Emulation and Dart.PowerTCP.Telnet).
    6. [C#]
Vt vt1 = new Vt();
Telnet session = new Telnet();
[Visual Basic]
Dim vt1 as New Vt()
Dim session as New Telnet()
  6. Add the following code to the button "on-click" event handler immediately after the code to create theVt control and Telnet component. Most of the time when the Vt control will be used dynamically, Telnet communications will occur through a separate instance of the Telnet component rather than the built-in property of Vt.Telnet. The built-in telnet capability of Vt is only intended for standard usage as part of a visual control.
    7. [C#]
string data;

// Set the Telnet Timeout to 3 seconds.
session.ReceiveTimeout = 3000;
Segment Seg;// The data segment that will contain received data
Seg = session.Login("myservername", "user", "password", "$");// login
data = Seg.ToString(); // Accumulate segment information into string

// Assume login was successful, now send the command for a listing.
Seg = session.Send("ls\r\n");
data+=Seg.ToString();// Keep appending any returned data

// Receive the response
string s= session.WaitFor("$");
data+=s;

session.Close();// close the connection

vt1.BufferRows = 0; // Remove buffers as this isn’t going to be visible in Vt

vt1.Write(data);// Feed the string into Vt

// Display the scraped data
MessageBox.Show(vt1.ScrapeText(0,vt1.TextLength));
[Visual Basic]
Dim data As String

' Set the Telnet Timeout to 3 seconds.
session.ReceiveTimeout = 3000
Dim Seg As Segment ' The data segment that will contain received data
Seg = session.Login("myservername", "user", "password", "$")' login
Data = Seg.ToString() ' Accumulate segment information into string

' Assume login was successful, now send the command for a listing.
Seg = session.Send("ls" + vbCrLf)
data += Seg.ToString() ' Keep appending any returned data

' Receive the response
Dim s As String
s = session.WaitFor("$")
Data += s

session.Close() ' close the connection

vt1.BufferRows = 0 ' Remove buffers as this isn’t going to be visible in Vt

vt1.Write(Data) ' Feed the string into Vt

' Display the scraped data
MessageBox.Show(vt1.ScrapeText(0,vt1.TextLength))
  7. Add a licenses.licx file to the project as described in Creating the Licenses.licx File.
  8. Navigate to the Debug menu and choose Start. The application will compile and execute.

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2003 Dart Communications. All rights reserved.


Creating the Licenses.licx File

Note: If you are creating a component by dragging it from the toolbox, you do not need to create a licenses.licx file, as one will be created by the environment. These steps apply only if you are using a component as a reference, or from a non-Visual Studio .NET environment.

To create a licenses.licx file, use the following steps (This example demonstrates using the Vt control).

  1. Start a new application in Visual Studio .NET 2003 and add the Vt control as a reference.
  2. In the Solution Explorer, right-click the project name, choose Add, then Add New Item.
  3. From the resulting dialog box, choose Text File and name the file "licenses.licx". Click Open.
  4. Type the following in the licenses.licx file

    Dart.PowerTCP.Emulation.Vt, Dart.PowerTCP.Emulation.Vt

    and save the file. You should now be able to compile and run a project that uses the Vt control as a reference.

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Using a PowerTCP Component in Your Own Custom DLL

PowerTCP components can be used within a standard desktop application (EXE), a Web Service, a Windows Service, an ASP.NET application, and your own custom dynamic-link library (DLL). It is not necessary to provide licensing information for the custom dll, however it is necessary for any application which uses the custom dll. For example, if you have a dll ("Helper.dll") that uses a PowerTCP component it is not necessary to provide licensing info for the dll. However, if you have an an application ("App1.exe") that references "Helper.dll", the application will have to have a "licenses.licx" file containing the component information for the PowerTCP component (see Creating The Licenses.licx File for more information about creating "licenses.licx" files). In addition, "App1.exe" must be compiled on a machine that has a properly registered PowerTCP component.

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Synchronous Versus Asynchronous Methods

The decision of whether to use synchronous or asynchronous methods can be crucial and have an impact on the complexity of your code and the user experience.

The following lists discuss some of the characteristics of synchronous and asynchronous methods in PowerTCP.

Synchronous Methods

  • Are easier to implement and use than asynchronous.
  • Do not require an event to implement.
  • Results are returned directly from the method call.
  • Error handling occurs during the method call.

Asynchronous Methods

  • Occur on a new thread.
  • Are slightly more difficult to implement and use than synchronous.
  • Must have an event handler to handle the response.
  • Results are returned to the event handler.
  • Error handling occurs within the associated event handler.

Most applications written with PowerTCP will be synchronous. The reasons for this are not purely due to the ease-of-use of synchronous methods. Synchronous methods are ideal for automated processes that can execute a blocking method for a period of time. In addition, synchronous methods can work well for interactive applications. The Object.DoEvents property controls the processing of user interface messages while a synchronous method is executing. This means that while a synchronous method is executing, other portions of the application will be able to respond to events (for example, button or menu clicks).

Asynchronous methods, on the other hand, provide a great deal of power. When an asynchronous method is called, the method will execute on a thread separate from the calling thread. Such operation is useful when an action is time consuming and other code needs to execute without waiting for the initial operation to complete. In addition, the user interface will be most responsive when asynchronous methods are used. Asynchronous methods are generally required for interactive on-line applications such as emulators, where received data must be displayed whenever it arrives.

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Using The Vt Control

PowerTCP Emulation for .NET is designed for both users who require little configuration and just want basic terminal emulation and users who require more advanced requirements with respect to configuration and control of the Telnet connection. This section is focused on providing examples of very simple usage to get you up and running in the shortest possible time.

In This Section

Building an Emulator (Internal Telnet)
Describes how to build an asynchronous emulator application using the internal Telnet control.
Building a Scripted Emulator (External Telnet)
Describes how to build a scripted (blocking) emulator using the external Telnet control.
Using Keymapping with the Vt Control
Discusses how to perform keymapping (substituting a sequence of characters for a keyboard stroke).
Screen Scraping
Discusses techniques to scrape (retrieve) text from the VT window.
Resizing The Vt Control
Discusses techniques for resizing the VT window.
About Fonts
Discusses the design decisions regarding PowerTCP's raster-capable fonts.

Related Sections

Getting Started
Provides an overview of PowerTCP Emulation for .NET and discusses such topics as distribution, licensing, and support.
Using PowerTCP within Visual Studio .NET
Demonstrates how to create a project and add a PowerTCP component.
Using Events in PowerTCP
Discusses how to use the events provided by PowerTCP Emulation for .NET.
Reference
Provides a language/syntax reference for PowerTCP Emulation for .NET.
Samples
Describes the samples that are installed with PowerTCP Emulation for .NET.

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2003 Dart Communications. All rights reserved.


Building an Emulator (Internal Telnet)

This topic and subtopics illustrate how to create an emulator application using the internal Telnet control (the Telnet control exposed by the Vt.Telnet property). This is the quickest and easiest way to create an emulation application, and because the Vt control handles the sending/receiving of all data, you only need to be concerned with connecting/disconnecting the Telnet connection. However, there are some limitations. For example, the internal Telnet control always works in a non-blocking fashion. If you require blocking techniques, you will have to use the external Telnet control. See Building a Scripted Emulator (External Telnet). You also lose the capability for automatic event subscription (in VB.NET, this is still possible in C#); you must explicitly "wire up" and Telnet specific events in the code manually. This is addressed in the "Monitoring connection status" topic below.

The following subtopics are addressed:

  • Preparing the form
  • Connecting to a Telnet server
  • Monitoring connection status
  • Closing Telnet connection

Preparing the form

In order to properly follow the instructions in this topic, prepare your application as described in the following steps.

  1. Create a new Windows application in Visual Studio .NET.
  2. Add the Vt control to the new form. For instructions on how to do this see Using PowerTCP within Visual Studio .NET 2003.
  3. Within the Properties Window, set Vt.Dock to DockStyle.Fill. The Vt Control should fill all available space in the Form.
  4. Go to the Toolbox and double click the MainMenu control to add a menu to your form.
  5. Click the MainMenu control and add the following menu items:
    • Connect (Text = "Connect", Name = mnuConnect)
    • Close Connection (Text = "Close Connection", Name = mnuCloseConnection)

Connecting to a Telnet server

To connect, simply call the Connect method of the internal Telnet component (exposed by the Vt.Telnet property) as described in the following steps:

  1. Double click on the "Connect" menu item created in the first step of the topic to implement the click event of this menu option.
  2. Within the click event of this menu item, add the following code:
    3. [Visual Basic]
' Connect to a Telnet server
vt1.Telnet.Connect("myservername")
[C#]
// Connect to a Telnet server
vt1.Telnet.Connect("myservername");

Monitoring connection status

While writing your code, you will often need to monitor the status of the connection so that action can be taken when the connection status changes, especially if the connection change is unexpected. When the connection changes, the vt1_Telnet_ConnectedChanged event will be raised.

  1. Create a method to handle the Telnet.ConnectedChanged event:
    2. [Visual Basic]
Private Sub TelnetConnectedChanged(ByVal sender As Object, ByVal e as System.EventArgs)
   If vt1.Telnet.Connected  = True Then
      Me.Text = "[Connected to " & vt1.Telnet.RemoteEndPoint.Address.ToString() & ":" & vt1.Telnet.RemoteEndPoint.Port.ToString() & "]"
   Else
      Me.Text = "Unconnected"
   End If
End Sub
[C#]
private void TelnetConnectedChanged(object sender, System.EventArgs e)
{
   if (vt1.Telnet.Connected)
      this.Text = "[Connected to " + vt1.Telnet.RemoteEndPoint.Address.ToString() + ":" + vt1.Telnet.RemoteEndPoint.Port.ToString() + "]";
   else
      this.Text = "Unconnected";
}
  2. Wire up the Telnet.ConnectedChanged event to the handler method you just created. This can be done within the Form Load event.
    3. [Visual Basic]
AddHandler vt1.Telnet.ConnectedChanged, New System.EventHandler (AddressOf TelnetConnectedChanged)
[C#]
vt1.Telnet.ConnectedChanged += new System.EventHandler(TelnetConnectedChanged);
  3. At this point, the ConnectedChanged event should be wired up and ready.

Closing Telnet connection

Once a session is complete, you will want to close the connection to the server gracefully.

  1. Double click on the "Close Conenction" menu item created in the first step of the topic to implement the click event of this menu option.
  2. Within the click event of this menu item, add the following code:
    3. [Visual Basic]
' Close the connection
vt1.Telnet.Close()
[C#]
// Close the connection
vt1.Telnet.Close();

Once all of the above steps have been completed, compile and run the application. Choose "Connect" from the menu to connect to your server. You should see your login prompt. Type your login info to login to your Telnet server.

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Building a Scripted Emulator (External Telnet)

As discussed in the topic Building an Emulator (Internal Telnet), building an emulator application using the Vt's internal Telnet control is certainly the quickest and easiest way to write an emulator application, but does have some minor limitations:

  • The internal Telnet control always operates asynchronously.
  • In VB.NET you lose the capability for automatic event subscription within the envionrment.
This topic discusses how you can remedy these limitations using an external Telnet control (an external Telnet control means you aren't using the Telnet control provided as a property of the Vt control, but a new instance of Telnet that is separate from the Vt control). The limitations of this approach are you lose the automatic support for data sending/receiving, so this must be done explicitly as described below.

Note, a scripting application by definition will not require interactive user input, but will simply execute a preset script of commands. If you need to build an interactive emulator, please refer to Building an Emulator (Internal Telnet).

The following subtopics are addressed:

  • Preparing the form
  • Connecting to a Telnet server
  • Sending data
  • Receiving data
  • Closing Telnet connection

Preparing the form

In order to properly follow the instructions in this topic, prepare your application as described in the following steps.

  1. Create a new Windows application in Visual Studio .NET.
  2. Add the Vt control to the new form. For instructions on how to do this see Using PowerTCP within Visual Studio .NET 2003.
  3. Add the Telnet component to the new form in the same way (note, you may have to add the Telnet component to the Toolbox, which is in the Dart.PowerTCP.Telnet namespace).
  4. Add a button to the form called "Test Script". This will simulate running the script. Typically, the script will be run by some other event, such as a daily or hourly process.

Connecting to a Telnet server

To connect, simply call the Login method (which connects and logs in with one step) of the Telnet component. Double click on the "Test Script" button created in the first step of the topic to implement the click event of this button. Within the click event of this button, add the following code:

[Visual Basic]
' ReceiveTimeout must be set to a positive value before using the Login method.
Telnet1.ReceiveTimeout = 3000

' Connect and login to the Telnet server
Telnet1.Login("myserver", "myusername", "mypassword", "$")

' Once this has successfully completed, you are connected
 Me.Text = "[Connected to " & vt1.Telnet.RemoteEndPoint.Address.ToString() & ":" & vt1.Telnet.RemoteEndPoint.Port.ToString() & "]"
[C#]
// ReceiveTimeout must be set to a positive value before using the Login method.
telnet1.ReceiveTimeout = 3000;

// Connect and login to the Telnet server
telnet1.Login("myserver", "myusername", "mypassword", "$");

// Once this has successfully completed, you are connected
this.Text = "[Connected to " + vt1.Telnet.RemoteEndPoint.Address.ToString() + ":" + vt1.Telnet.RemoteEndPoint.Port.ToString() + "]";

Sending data

To send data, simply call the Telnet.Send method. Place this code immediately after the "Login" code above.

[Visual Basic]
' Send PWD command
Telnet1.Send("PWD" + vbCrLf)
[C#]
// Send PWD command
telnet1.Send("PWD\r\n");

Receiving data

Once data has been sent, we expect a response, so wait for it using the Telnet.WaitFor method. Also, since this isn't an interactive application (therefore there is presumably not a user looking at the Vt window) this code simply scrapes the data from the window (thereby removing any escape sequences) and saves it to a database. Place this code immediately after the "Send" code above.

[Visual Basic]
' Receive response
Dim s as String = Telnet1.WaitFor("$ ")

' Display the response on the Vt window
vt1.Write(s)

' Scrape the content
Dim content as String = vt1.ScrapeText(0, vt1.TextLength)

' Do something with the scraped text...in this example a user-defined function to
' save it to a database is called.
MySaveToDatabase(content)
[C#]
// Receive response
string s = telnet1.WaitFor("$ ")

// Display the response on the Vt window
vt1.Write(s);

// Scrape the content
string content = vt1.ScrapeText(0, vt1.TextLength);

// Do something with the scraped text...in this example a user-defined function to
// save it to a database is called.
MySaveToDatabase(content);

Closing Telnet connection

Once the scripting operation is complete, you will want to close the connection to the server gracefully. Place this code immediately after the "Receive" code above.

[Visual Basic]
' Close the connection
telnet1.Close()
[C#]
// Close the connection
telnet1.Close();

Once all of the above steps have been completed, compile and run the application. Click the button to test the script.

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Screen Scraping

Screen scraping refers to extracting visual data from a remote server in a form that can be programmatically accessed. For example, a terminal emulator can be used to run a report on a remote server, but you would also like access to the data presented in that report. Screen scraping is the mechanism of getting that data and returning it to the user in a manner that can be manipulated programmatically. One of the challenges of screen scraping VT data is that it is decorated by escape characters that define the visual representation, such as font colors, bold, italic, etc. PowerTCP Emulation for .NET provides several mechanisms for getting access to this data.

The following subtopics are addressed:

  • Getting data to the Vt control
  • Getting text from the Vt control
  • Getting styles from the Vt control

Getting data to the Vt control

Normally, the Vt control receives data during a session using Telnet communications, either with the built-in Telnet capability or an external Telnet component. Once data is available in the Vt buffer (which is visible in the control), that data is available for scraping. Often times, data has been received using Telnet into an external file or data buffer and needs to be scrapped so it can be sent to some type of automatic process. This data may or may have escape sequences that need to be removed or interpreted. In any case, the Vt.Write method is used to pass data to the Vt control. The Vt control can be dynamically instantiated (See Adding a Control as a Reference for more information) and used as a data scraper. The Write method takes for possible overloads:

  • Vt.Write(string) is the most common usage. This overload will take any string and remove all escape codes, while preserving stylistic information. If used as a visual control, the data is visible in the control with all the stylistic information.
  • Vt.Write(byte[], int, int) will accept a byte array, with an offset value for the second parameter, and a count for the third parameter. This technique is useful if your data is in the form of a byte array, which is often the result of an external Telnet or TCP connection.
  • Vt.Write(byte[]) will accept a byte array and call the above method.
  • Vt.Write(stream) will accept any source stream as a data source. This allows for extensive flexibility when data is available through a stream interface.

Getting text from the Vt control

One of the most common uses of the Vt control, besides displaying terminal information, is returning text from the remote server in a useful fashion. There are several techniques for extracting text from the Vt control, depending on your needs. The ScrapeText method can be used to access the text with two overloads. Use the following code to extract text from a Vt control. This example assumes you already have a Vt control on a form.

[Visual Basic]
' Set the BufferRows to 0 to avoid dealing with empty spaces
vt1.BufferRows = 0

'scrape text, starting at position 0 and extending to the length of the text
MessageBox.Show(vt1.ScrapeText(0,vt1.TextLength))
[C#]
//Set the BufferRows to 0 to avoid dealing with empty spaces
vt1.BufferRows = 0;

//scrape text, starting at position 0 and extending to the length of the text
MessageBox.Show(vt1.ScrapeText(0,vt1.TextLength));

The second overload uses X-Y coordinate information, rather than character position if the requirement is to access the text based on rows and columns. The following code, ScrapeText(4,5,8), will return text starting at row 4, column 5, and then include the next 8 characters. Please note that the positioning system is zero-based.

Getting styles from the Vt control

Often, when scraping data from the Vt control, pure text is not enough. VT emulation types often support stylistic effects that make a presentation more aesthetically pleasing or highlight certain aspects of text with color. The Vt control preserves stylistic information about a position on the screen using an array of cell that represent the VT screen. Every cell contains information about a screen position, including, foreground and background color, whether a character is bold, underlined, or blinking, whether its double high, or double wide, inverse, or if it’s a graphic character. The following assumes that a Vt control is already on a form and data has been passed to the control. This example demonstrates how style information can be used to translate style data into other graphic rich formats.

Note, the following code can be replaced by the Vt.ScrapeHtml method, but is demonstrated here in case you wish to customize your HTML output.

[Visual Basic]
Dim Cells As Cell()	‘holds the cells representing the styles
Cells = Vt1.ScrapeCells(0, Vt1.TextLength) 'scrape style info - mapped 1-to-1 with the bytes returned from ScrapeText
Dim s As String = "<FONT Face = ""Lucida Console"" <p><br>" 'Use Lucida Console as that matches console apps
Dim i As Integer

For i = 0 To Cells.Length - 1
   If Cells (i).Character = 32 Then 'replace space with
      s += " "
   ElseIf Cells (i).Character = 13 Then 'replace CRLF with breaks and move on ahead to account for the next LF byte
      s += "<br>"
      i = i + 1
   Else
      If (Cells (i).Styles = Styles.Bold) Then 'check if Bold
         s += "<b>"
         s += Cells(i).ToString()
         s += "</b>"
      ElseIf (Cells (i).Styles = Styles.Underline) Then 'check if underline
         s += "<u>"
         s += Cells(i).ToString()
         s += "</u>"
      ElseIf (Cells (i).Styles = Styles.Blink) Then 'check in blink
         s += "<blink>"
         s += Cells(i).ToString()
         s += "</blink>"
      Else
         s += Cells(i).ToString() 'No style info, just write out the text.
      End If
   End If
Next i

s += "</p></FONT>" 'finish the HTML block.
[C#]
Cell[] cells;	//holds the cells representing the styles
cells = Vt1.ScrapeCells(0, Vt1.TextLength );	//scrape style info - mapped 1-to-1 with the bytes returned from ScrapeText
string s = "<FONT Face = \"Lucida Console\"><p><br> >";	//Use Lucida Console as that matches console apps

for(int i=0; i<cells.Length; i++)
{
   if(cells[i].Character ==32)	//replace space with
      s+=" ";
   else if(cells[i].Character==13)	//replace CRLF with breaks and move on ahead to account for the next LF byte
   {
      s+="<br>";
      i++;
   }
   else
   {
      if(cells[i].Styles==Styles.Bold)	//check if Bold
      {
         s+="<b>";
         s+= cells[i].ToString();
         s+= "</b>";
      }
      else if(cells[i].Styles==Styles.Underline)	//check if underline
      {
         s+="<u>";
         s+= cells[i].ToString();
         s+= "</u>";
      }
      else if(cells[i].Styles==Styles.Blink)	//check if blink
      {
         s+="<blink>";
         s+= cells[i].ToString();
         s+= "</blink>";
      }
      else
         s+= cells[i].ToString();	//No style info, just write out the text.
   }
}
s+="</p></FONT>";	//finish the HTML block.

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Using Keymapping with the Vt Control

Keymapping refers to the process of replacing the value generated by a keystroke with another character (or combination of characters) before sending to the host. Typically, this is specific to the particular VT terminal that is being emulated. For this example, the following contrived example is used:

  • When <SHIFT> H is typed "Hello World" is sent.
  • When <CTRL> B is typed "Blah" is sent.
For this to occur, the keystroke is "detected" within the Vt.KeyDown event. If the one of the above keystroke combinations are found, the replacement characters can be sent.

To create a simple app that demonstrates keymapping.

  1. Create a new Windows application in Visual Studio .NET.
  2. Add the Vt control to the new form. For instructions on how to do this see Using PowerTCP within Visual Studio .NET 2003.
  3. Double click the Form to enter the Form Load event.
  4. Within this event, add the following code to connect to a Telnet server:
    [Visual Basic]
' Connect to your Telnet server
vt1.Telnet.Connect("myserver")

[C#]
// Connect to your Telnet server
vt1.Telnet.Connect("myserver");
  5. Implement the Vt.KeyDown event. For instructions on how to do this, see the Using events in PowerTCP topic.
  6. Within the KeyDown event, place your handling code to check for keystrokes. If a matching keystroke is found, send the associated replacement sequence. Your KeyDown event code should look similar to the following:
    7. [Visual Basic]
Private Sub vt1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles vt1.KeyDown
   ' Handle Keymappping. Recall there are two cases we are checking for:
   ' 1) Shift key plus "H"...send "Hello World"
   ' 2) Control key plus "B"...send "Blah"
   If e.Shift = True And e.KeyCode = Keys.H Then
      vt1.Telnet.Send("Hello World" + vbCrLf)
      e.Handled = true ' Mark the event as handled so no more key events are raised
   End If

   If e.Control = True And e.KeyCode = Keys.B Then
      vt1.Telnet.Send("Blah" + vbCrLf)
      e.Handled = True ' Mark the event as handled so no more key events are raised
   End If
End Sub

[C#]
private void vt1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
   // Handle Keymappping. Recall there are two cases we are checking for:
   // 1) Shift key plus "H"...send "Hello World"
   // 2) Control key plus "B"...send "Blah"
   if(e.Shift == true && e.KeyCode == Keys.H)
   {
      vt1.Telnet.Send("Hello World\r\n");
      e.Handled = true; // Mark the event as handled so no more key events are raised
   }

   if(e.Control == true && e.KeyCode == Keys.B)
   {
      vt1.Telnet.Send("Blah\r\n");
      e.Handled = true; // Mark the event as handled so no more key events are raised
   }
}
  7. Compile and run the application. When the Form_Load event is raised, the Vt control should attempt to connect to your Telnet server, presenting you with a login sequence. Login to your Telnet server. Send one of the keystroke combinations to test that the keymapping works.

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Resizing The Vt Control

You may wish to add code that will control the size of the form based on the size of the font being used for interactive data entry in the Vt control. When doing this, there are two scenarios to consider, a non-docked Vt control and a docked Vt control. Docking refers to a .NET Framework technique whereby a windows control can be preset to occupy its container one of several predefined ways. For example, Vt.Dock can be set to DockStyle.Fill to completely fill it's parent container (typically, the parent Form). By default, Vt.Dock is DockStyle.None, meaning no docking is used. The simpler of the two scenarios (the non-docked control) is addressed first.

Resizing a non-docked Vt control

When the Vt control is not docked, it can automatically be resized by using the Vt.Resize method.

  1. Create a new Windows application in Visual Studio .NET.
  2. Add the Vt control to the new form. For instructions on how to do this see Using PowerTCP within Visual Studio .NET 2003. Be sure that the Vt.Dock property is left to it's default.
  3. Double click the Form to enter the Form Load event.
  4. Within this event, add the following code:
    [Visual Basic]
' Write some text to the Vt Window so the change will be more apparent.
vt1.Write("Hello world")

' Block so the user can see the default behavior.
MessageBox.Show("Default size")

' Change the font size to 15
vt1.SetDefaultFont(15)

' Call the Resize method to automatically resize.
vt1.Resize()

' Block so the user can see the change.
MessageBox.Show("Resized to 15")
[C#]
// Write some text to the Vt Window so the change will be more apparent.
vt1.Write("Hello world");

// Block so the user can see the default behavior.
MessageBox.Show("Default size");

// Change the font size to 15
vt1.SetDefaultFont(15);

// Call the Resize method to automatically resize.
vt1.Resize();

// Block so the user can see the change.
MessageBox.Show("Resized to 15");
  5. Compile and run the application. You should see the form resize when it loads.

Resizing a docked VT control.

Often, windows applications will use some sort of docking for the Vt control. In these scenarios the Vt.Resize method will not work, as the Vt control will always follow the DockStyle specified. For example, if Vt.Dock = DockStyle.Fill, the Vt control will always fill the parent form. To resize in a scenario like this one, you must calculate the new size of the Vt control, and perform the resize on the parent form.

  1. Create a new Windows application in Visual Studio .NET.
  2. Add the Vt control to the new form. For instructions on how to do this see Using PowerTCP within Visual Studio .NET 2003. Within the Properties Window, set Vt.Dock to DockStyle.Fill. The Vt Control should fill all available space in the Form.
  3. Double click the Form to enter the Form Load event.
  4. Within this event, add the following code:
    [Visual Basic]
' Write some text to the Vt Window so the change will be more apparent.
vt1.Write("Hello world")

' Block so the user can see the default behavior.
MessageBox.Show("Default size")

' Change the font size to 15
vt1.SetDefaultFont(15)

' Resize the parent form based on the properties of the Vt control.
this.Height = (vt1.ScreenSize.Height * vt1.CharacterSize.Height) + vt1.Margin.Height + (this.Height - vt1.Height)
this.Width = (vt1.ScreenSize.Width * vt1.CharacterSize.Width) + vt1.Margin.Width +  SystemInformation.VerticalScrollBarWidth + (this.Width - vt1.Width)

' Block so the user can see the change.
MessageBox.Show("Resized to 15")
[C#]
// Write some text to the Vt Window so the change will be more apparent.
vt1.Write("Hello world");

// Block so the user can see the default behavior.
MessageBox.Show("Default size");

// Change the font size to 15
vt1.SetDefaultFont(15);

// Resize the parent form based on the properties of the Vt control.
this.Height = (vt1.ScreenSize.Height * vt1.CharacterSize.Height) + vt1.Margin.Height + (this.Height - vt1.Height);
this.Width = (vt1.ScreenSize.Width * vt1.CharacterSize.Width) + vt1.Margin.Width +  SystemInformation.VerticalScrollBarWidth + (this.Width - vt1.Width);

// Block so the user can see the change.
MessageBox.Show("Resized to 15");
  5. Compile and run the application. You should see the form resize when it loads.

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


About Fonts

The .NET Framework font support is encapsulated by the Font class in the System.Drawing namespace. As described in the MSDN topic Font Changes in Visual Basic .NET, .NET Framework fonts only support OpenType and TrueType fonts. However, Raster fonts are often used in VT Emulation applications. For this reason, PowerTCP Emulation for .NET defines a new Font class (Dart.PowerTCP.Emulation.Font) which supports both TrueType and Raster type fonts.

Since the Vt control derives from System.Windows.Forms.Control, it derives a Text property, which is a System.Drawing.Font type. Since PowerTCP Emulation for .NET does not use this type of Font object, this property is obsoleted and will throw an exception whenever it is used. To set the font of the Vt control, use the Vt.FontEx property, which is a Dart.PowerTCP.Emulation.Font type.

  • Namespace conflicts
  • Incompatibility
  • Creating a Font class
  • Using the FontDialog class

Namespace conflicts

In some environments (such as a VS.NET C# application) you may have namespace conflicts between the two Font classes. For example, when you create a new Windows C# application, "using System.Drawing" is included at the top of the class. If you add "using Dart.PowerTCP.Emulation" to the top of the form, then try to create a Font object without specifying the namespace such as,

[C#]
Font f = new Font("courier", (float)7.5);
you will get an ambiguous match error, as the environment cannot determine which Font object you wish to create. For this reason, when creating Font objects (or Font related objects such as FontDialog...see below) always use the fully qualified namespace like so:
[C#]
Dart.PowerTCP.Emulation.Font f = new Dart.PowerTCP.Emulation.Font("courier", (float)7.5);

Incompatibilty

Dart.PowerTCP.Emulation.Font is incompatible with System.Drawing.Font, so you can't directly use a System.Drawing.Font object for the Vt.FontEx property, and similarly you can't use a Dart.PowerTCP.Emulation.Font type as a replacement for a System.Drawing.Font value (such as System.Windows.Forms.TextBox.Font). If necessary, you could perform a "mapping" between the two types (for example, creating a new Dart.PowerTCP.Emulation.Font based on the property values of a System.Drawing.Font type).

Creating a Font class

The following code demonstrates creating a new Dart.PowerTCP.Emulation.Font object and applying it to the Vt window.

[Visual Basic]
' Create a new Font object
Dim f as Dart.PowerTCP.Emulation.Font
f = New Dart.PowerTCP.Emulation.Font("courier", 7.5, FontStyle.Bold + FontStyle.Italic)

' Set the Vt font to the newly created Font
vt1.FontEx = f
[C#]
// Create a new Font object
Dart.PowerTCP.Emulation.Font f;
f = new Dart.PowerTCP.Emulation.Font("courier", (float)7.5, FontStyle.Bold | FontStyle.Italic);

// Set the Vt font to the newly created Font
vt1.FontEx = f;

Using the FontDialog class

PowerTCP Emulation for .NET also includes a FontDialog class which can be used to display a dialog to the user, enabling them to choose a Dart.PowerTCP.Emulation.Font type, as the following code demonstrates:

[Visual Basic]
' Create a new Dart.PowerTCP.Emulation.FontDialog class
Dim fDialog As New Dart.PowerTCP.Emulation.FontDialog()

' Show the dialog.
If fDialog.ShowDialog() = DialogResult.OK Then
   ' Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font
End If
[C#]
// Create a new Dart.PowerTCP.Emulation.FontDialog class
Dart.PowerTCP.Emulation.FontDialog fDialog = new Dart.PowerTCP.Emulation.FontDialog();

// Show the dialog.
if(fDialog.ShowDialog() == DialogResult.OK)
{
   // Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font;
}

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2003 Dart Communications. All rights reserved.


Using Events In PowerTCP

This topic discusses how to implement PowerTCP events within your application.

In This Section

Using Events within the Visual Studio .NET Environment
Describes how to use PowerTCP events within the Visual Studio .NET environment.
Using Events When a Component is Used as a Reference
Describes the extra steps required to use events when using a PowerTCP component as a reference.

Related Sections

Getting Started
Provides an overview of PowerTCP Emulation for .NET and discusses such topics as distribution, licensing, and support.
Using PowerTCP within Visual Studio .NET
Demonstrates how to create a project and add a PowerTCP component.
Using the Vt Control
Discusses how to use the Vt component to display data.
Reference
Provides a language/syntax reference for PowerTCP Emulation for .NET.
Samples
Describes the samples that are installed with PowerTCP Emulation for .NET.

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2003 Dart Communications. All rights reserved.


Using Events within the Visual Studio .NET Environment

The Visual Studio .NET environment has built-in support for "wiring-up" and using component events, making their use simple.

To "wire-up" an event using the Visual Studio environment using VB.NET, use the following steps. (Steps for C# follow).

  1. Start a new VB.NET project and add a component to the form (see Creating an Instance of a Component Using Visual Studio .NET for information on how to do this). For this example, the Vt control is used.
  2. Navigate to View, and then select Code to switch to code view.
  3. From the "drop-down" boxes at the top of the Code Window, select the instance of the Vt control from the box on the left, and then the name of the event you would like to "wire-up" from the box on the right (see screenshot below).

  4. After doing this, the Visual Studio .NET environment will transparently create the necessary code to "wire-up" the event. The code should look similar to the following (using the Vt.KeyDown event as an example).
    5. Private Sub vt1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles vt1.KeyDown
   ' Write event handling code here.
End Sub
  5. Now the Vt.KeyDown event will be raised with each key press.

To "wire-up" an event using the Visual Studio environment using C#, use the following steps.

  1. Start a new C# project and add the Vt control to the form (see Using a Component within Visual Studio .NET for information on how to do this).
  2. Click the component icon, created on the panel underneath the form.
  3. On the Properties Window click the "lightning bolt" icon to display all events for the Vt control.
  4. Double-click the event you wish to "wire-up" (see screenshot below).

  5. After doing this, the Visual Studio .NET environment will automatically create the necessary code to "wire-up" the event. The code should look similar to the following (using the Vt.KeyDown event as an example).
    6. private void vt1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
   // Write event handling code here.
}
  6. Now the Vt.KeyDown event will be raised with each key press.

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Using Events When a Component is Used as a Reference

PowerTCP Emulation for .NET

Using Events When Using a Component as a Reference

If you are using the PowerTCP component as a reference (instead of adding it to the project as a component), and would like to use events, you must "wire-up" the event manually. This topic addresses how to do this using either VB.NET or C#. Note: You do NOT need to "wire-up" the events manually if you are dragging an instance of a PowerTCP component onto the form while using Visual Studio .NET. In this case all event subscription will be handled by the environment.

To use events when using a PowerTCP component as a class and creating a VB.NET Windows Application, use the following steps (steps for C# below).

  1. Start a new VB.NET project and add a PowerTCP component as a reference (see Adding a Component as a Reference within Visual Studio .NET for information of how to do this). In this example, the Vt control is used.
  2. Navigate to the View menu and then select Code to switch to code view.
  3. Create an instance of the Vt class. Be sure to use the WithEvents keyword such as in the following:
    4. Private WithEvents Vt1 As New Dart.PowerTCP.Emulation.Vt()
  4. You must create a method that implements the appropriate delegate. The first step is to determine which event you would like to "wire-up". For the purposes of this walkthrough, the Vt.KeyDown event will be used, although other events would work in a similar manner.
  5. Navigate to the Vt.KeyDown event in the Reference section.
  6. The syntax definition for the appropriate language specifies which delegate is implemented by the event. For example the VB.NET syntax for the Vt.KeyDown event is:
    7. public Event KeyDown As KeyEventHandler
    In other words, to "wire-up" the Vt.KeyDown event, you must first create a method that implements the KeyEventHandler delegate.
  7. Navigate to the reference listing for the System.Windows.Forms.KeyEventHandler delegate. This listing will tell you what your event-handler method should look like. According to the KeyEventHandler delegate, your method must accept two arguments (an object and a KeyEventArgs object) and return nothing, so create a method that does this. This method should look similar to the following:
    8. Private Sub MyKeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
   ' Write code to handle the event here.
End Sub
  8. Finally, the event handler must "subscribe" to the event. In VB.NET, this can simply be done by using the "Handles " keyword next to the event handler as such:
    9. Private Sub MyKeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Vt1.KeyDown
   ' Write code to handle the event here.
End Sub
  9. Alternatively, you can use the AddHandles keyword to "subscribe" an event handler to an event. This is done like so:
    10. AddHandler Vt1.KeyDown, AddressOf Me.MyKeyDown
  10. Now the Vt.KeyDown event will be raised with each keystroke.

To use events when using a PowerTCP component as a reference and creating a C# Windows Application, use the following steps.

  1. Start a new C# project and add a PowerTCP component as a reference (see Adding a Component as a Reference within Visual Studio .NET for information of how to do this. In this example, the Vt control is used.
  2. Navigate to the View menu, and then select Code to switch to code view.
  3. Create an instance of the Vt class such as:
    4. private Dart.PowerTCP.Emulation.Vt vt1 = new Dart.PowerTCP.Emulation.Vt();
  4. Now you must create a method that implements the appropriate delegate. The first step is to determine which event you would like to "wire-up". For the purposes of this walkthrough, the Vt.KeyDown event will be used, although other events would work in a similar manner.
  5. Navigate to the Vt.KeyDown event in the Reference section.
  6. The syntax definition for the appropriate language specifies which delegate is implemented by the event. For example the C# syntax for the Vt.KeyDown event is:
    7. public event KeyEventHandler KeyDown;
    In other words, to "wire-up" the Vt.KeyDown event, you must first create a method that implements the System.Windows.Forms.KeyEventHandler delegate.
  7. Navigate to the reference listing for the System.Windows.Forms.KeyEventHandler delegate. This listing will tell you what your event-handler method should look like. According to the KeyEventHandler delegate, your method must accept two arguments (an object and a KeyEventArgs) and return void, so create a method that does this. This method should look similar to the following:
    8. private void MyKeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
   // Write code to handle the event here.
}
  8. Finally, the event handler must "subscribe" to the event. In C#, this can be done as such (put this code in your form initialization):
    9. vt1.KeyDown += new Dart.PowerTCP.Emulation.KeyEventHandler(this.MyKeyDown);
  9. Now the Vt.KeyDown event will be raised with each keystroke.

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


PowerTCP Emulation for .NET Reference

This section contains reference documentation for all of the objects and classes that comprise Emulation for .NET. This section is intended solely for use as a class reference guide for use while building an application. It is NOT intended to give a "walkthrough" type description of usage. For a description of this type, see the higher-level topics.

In This Section

Dart.PowerTCP.Emulation Namespace
Contains classes that support and enable creation of VT applications in the .NET environment.

Related Sections

Getting Started
Provides an overview of PowerTCP Emulation for .NET and discusses such topics as distribution, licensing, and support.
Using PowerTCP within Visual Studio .NET
Demonstrates how to create a project and add a PowerTCP component.
Using the Vt Control
Discusses how to use the Vt component to display data.
Using Events in PowerTCP
Discusses how to use the events provided by PowerTCP Emulation for .NET.
Samples
Describes the samples that are installed with PowerTCP Emulation for .NET.

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Dart.PowerTCP.Emulation

PowerTCP Emulation for .NET

Dart.PowerTCP.Emulation Namespace

Classes

Class | Description
DataEventArgs | Provides data for the KeyPress event.
Font | Defines a particular format for text, including font face, size, and style attributes.
FontDialog | Represents a common dialog box that displays a list of fonts that are currently installed on the system.
FontEditor | Provides a user interface to select and configure a Font object.
Telnet | For information on the Telnet class, please see the Telnet for .NET documentation.
Vt | Represents a terminal emulator used to display VT formatted data.

Structures

Structure | Description
Cell | Represents a single cell (occupied by a single character) on the Vt control.

Delegates

Delegate | Description
DataEventHandler | Represents the method that will handle the event that is raised when key input occurs.

Enumerations

Enumeration | Description
CharSet | Enumerates charsets used when creating Font objects.
CursorKeys | Enumerates the values of the Vt.CursorKeys property. The cursor keys can be set up to provide ANSI cursor control or application control.
CursorStyle | Enumerates the values of the Vt.CursorStyle property.
FontType | Specifies font types.
Keypad | Enumerates the values of the Vt.Keypad property. The keypad can generate numeric values or application-specific values.
NationalCharSet | Enumerates the national character sets exposed by the Vt.NationalCharSet property.
NewLine | Enumerates the end-of-line sequences sent to the host in response to an end of line character (ENTER key). Used by the Vt.NewLine property.
PrintType | Enumerates the printing types used by the Vt control.
Scroll | Enumerates the values of the Vt.ScrollType property. The display screen can perform smooth scrolling or jump scrolling.
Style | Enumerates the character styles for text. One or more of these values are added together to represent the style of each character.
Styles | Enumerates the styles for a cell. Used by the Cell.Styles property.
TerminalType | Enumerates the values of the Vt.TerminalType property.


Cell Structure

Represents a single cell (occupied by a single character) on the Vt control.

For a list of all members of this type, see Cell Members.

System.Object
ValueType
Cell

[Visual Basic]
Public Structure Cell
[C#]
public struct Cell

Remarks

The Vt.ScrapeCells method returns an array of Cell objects for the specified range. Examine the properties of these objects to determing the formatting of each cell. For example, if you use ScrapeCells to scrape the entire content of the Vt control:

            Cell[] cells = Vt.ScrapeCells(0,0,Vt1.TextLength);

Then cells[0].Character will return the first character contained on the Vt control, cells[0].Styles will return the styles applied to the object, etc.

Example

[Visual Basic, C#] The following example demonstrates using the ScrapeCells method to discover info about a cell.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

Private Sub ShowCellInfo(ByVal row As Integer, ByVal col As Integer)
   ' Scrape the row and column specified.
   Dim cells as Cell() = vt1.ScrapeCells(row, col, 1)

   ' Display info about the cell.
   textBox1.Text = "Character: " & cells(0).Character
   textBox1.Text = textBox1.Text & " (" & CChar(cells(0).Character) & ")" & vbCrLf
   textBox1.Text = textBox1.Text & "Raw Character: " & cells(0).RawCharacter
   textBox1.Text = textBox1.Text & " (" & CChar(cells(0).RawCharacter) & ")" & vbCrLf
   textBox1.Text = textBox1.Text & "Background color: " & cells(0).BackColor & vbCrLf
   textBox1.Text = textBox1.Text & "Foreground color: " & cells(0).ForeColor & vbCrLf
   textBox1.Text = textBox1.Text & "Styles: " & cells(0).Styles
End Sub

' Use the following code to test the function

' Disable buffer
vt1.BufferRows = 0

' Clear the display
vt1.Clear()

' Add some dummy data
vt1.Write(Chr(27) + "[1mTest " + Chr(27) + "[0mdata" + Chr(27) + "[7m blah " + Chr(27) + "[0m")

' Call the function
ShowCellInfo(0, 3)
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

private void ShowCellInfo(int row, int col)
{
   // Scrape the row and column specified.
   Cell[] cells = vt1.ScrapeCells(row, col, 1);

   // Display info about the cell.
   textBox1.Text = "Character: " + cells[0].Character;
   textBox1.Text+= " (" + (char)cells[0].Character + ")" + "\r\n";
   textBox1.Text+= "Raw Character: " + cells[0].RawCharacter;
   textBox1.Text+= " (" + (char)cells[0].RawCharacter + ")" + "\r\n";
   textBox1.Text+= "Background color: " + cells[0].BackColor + "\r\n";
   textBox1.Text+= "Foreground color: " + cells[0].ForeColor + "\r\n";
   textBox1.Text+= "Styles: " + cells[0].Styles;
}

// Use the following code to test the function

// Disable buffer
vt1.BufferRows = 0;

// Clear the display
vt1.Clear();

// Add some dummy data
vt1.Write("\x1b[1mTest \x1b[0mdata\x1b[7m blah \x1b[0m");

// Call the function
ShowCellInfo(0, 3);

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: Dart.PowerTCP.Emulation

Assembly: DocEmulation (in DocEmulation.dll)

See Also

Cell Members | Dart.PowerTCP.Emulation Namespace


Cell Members

Cell overview

Public Instance Constructors

Cell Constructor Initialize a new instance of Cell.

Public Instance Properties

BackColor | Returns the background color for the cell.
Character | Returns the character within the cell.
ForeColor | Returns the foregrounf color for the cell.
RawCharacter | Returns the unconverted character within the cell.
Styles | Returns Style values representing the styles applied to the cell.

Public Instance Methods

Equals (inherited from ValueType) | Indicates whether this instance and a specified object are equal.
GetHashCode (inherited from ValueType) | Returns the hash code for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from ValueType) | Returns the fully qualified type name of this instance.

See Also

Cell Class | Dart.PowerTCP.Emulation Namespace


Cell Constructor

Initialize a new instance of Cell.

[Visual Basic]
Public Sub New( _
ByVal val As UInt32, _
ByVal backColor As Color, _
ByVal foreColor As Color _
)
[C#]
public Cell(
uint val,
Color backColor,
Color foreColor
);

Parameters

val
backColor
The background color of the cell.
foreColor
The foreground color of the cell.

See Also

Cell Class | Dart.PowerTCP.Emulation Namespace


Cell Properties

The properties of the Cell structure are listed below. For a complete list of Cell structure members, see the Cell Members topic.

Public Instance Properties

BackColor | Returns the background color for the cell.
Character | Returns the character within the cell.
ForeColor | Returns the foregrounf color for the cell.
RawCharacter | Returns the unconverted character within the cell.
Styles | Returns Style values representing the styles applied to the cell.

See Also

Cell Class | Dart.PowerTCP.Emulation Namespace


Cell.BackColor Property

Returns the background color for the cell.

[Visual Basic]
Public ReadOnly Property BackColor As Color
[C#]
public System.Drawing.Color BackColor {get;}

Property Value

A System.Drawing.Color value specifying the background color for the cell.

Remarks

If no background color is specified for the cell, this property will return Color.Empty.

Example

[Visual Basic, C#] The following example demonstrates using the ScrapeCells method to discover info about a cell.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

Private Sub ShowCellInfo(ByVal row As Integer, ByVal col As Integer)
   ' Scrape the row and column specified.
   Dim cells as Cell() = vt1.ScrapeCells(row, col, 1)

   ' Display info about the cell.
   textBox1.Text = "Character: " & cells(0).Character
   textBox1.Text = textBox1.Text & " (" & CChar(cells(0).Character) & ")" & vbCrLf
   textBox1.Text = textBox1.Text & "Raw Character: " & cells(0).RawCharacter
   textBox1.Text = textBox1.Text & " (" & CChar(cells(0).RawCharacter) & ")" & vbCrLf
   textBox1.Text = textBox1.Text & "Background color: " & cells(0).BackColor & vbCrLf
   textBox1.Text = textBox1.Text & "Foreground color: " & cells(0).ForeColor & vbCrLf
   textBox1.Text = textBox1.Text & "Styles: " & cells(0).Styles
End Sub

' Use the following code to test the function

' Disable buffer
vt1.BufferRows = 0

' Clear the display
vt1.Clear()

' Add some dummy data
vt1.Write(Chr(27) + "[1mTest " + Chr(27) + "[0mdata" + Chr(27) + "[7m blah " + Chr(27) + "[0m")

' Call the function
ShowCellInfo(0, 3)
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

private void ShowCellInfo(int row, int col)
{
   // Scrape the row and column specified.
   Cell[] cells = vt1.ScrapeCells(row, col, 1);

   // Display info about the cell.
   textBox1.Text = "Character: " + cells[0].Character;
   textBox1.Text+= " (" + (char)cells[0].Character + ")" + "\r\n";
   textBox1.Text+= "Raw Character: " + cells[0].RawCharacter;
   textBox1.Text+= " (" + (char)cells[0].RawCharacter + ")" + "\r\n";
   textBox1.Text+= "Background color: " + cells[0].BackColor + "\r\n";
   textBox1.Text+= "Foreground color: " + cells[0].ForeColor + "\r\n";
   textBox1.Text+= "Styles: " + cells[0].Styles;
}

// Use the following code to test the function

// Disable buffer
vt1.BufferRows = 0;

// Clear the display
vt1.Clear();

// Add some dummy data
vt1.Write("\x1b[1mTest \x1b[0mdata\x1b[7m blah \x1b[0m");

// Call the function
ShowCellInfo(0, 3);

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Cell Class | Dart.PowerTCP.Emulation Namespace


Cell.Character Property

Returns the character within the cell.

[Visual Basic]
Public ReadOnly Property Character As Byte
[C#]
public byte Character {get;}

Remarks

If character is a special graphics character (in which case Cell.Styles will return the SpecialCharacters flag) a conversion may take place on the character before returning it. For the unconverted character, see the Vt.RawCharacter property.

Example

[Visual Basic, C#] The following example demonstrates using the ScrapeCells method to discover info about a cell.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

Private Sub ShowCellInfo(ByVal row As Integer, ByVal col As Integer)
   ' Scrape the row and column specified.
   Dim cells as Cell() = vt1.ScrapeCells(row, col, 1)

   ' Display info about the cell.
   textBox1.Text = "Character: " & cells(0).Character
   textBox1.Text = textBox1.Text & " (" & CChar(cells(0).Character) & ")" & vbCrLf
   textBox1.Text = textBox1.Text & "Raw Character: " & cells(0).RawCharacter
   textBox1.Text = textBox1.Text & " (" & CChar(cells(0).RawCharacter) & ")" & vbCrLf
   textBox1.Text = textBox1.Text & "Background color: " & cells(0).BackColor & vbCrLf
   textBox1.Text = textBox1.Text & "Foreground color: " & cells(0).ForeColor & vbCrLf
   textBox1.Text = textBox1.Text & "Styles: " & cells(0).Styles
End Sub

' Use the following code to test the function

' Disable buffer
vt1.BufferRows = 0

' Clear the display
vt1.Clear()

' Add some dummy data
vt1.Write(Chr(27) + "[1mTest " + Chr(27) + "[0mdata" + Chr(27) + "[7m blah " + Chr(27) + "[0m")

' Call the function
ShowCellInfo(0, 3)
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

private void ShowCellInfo(int row, int col)
{
   // Scrape the row and column specified.
   Cell[] cells = vt1.ScrapeCells(row, col, 1);

   // Display info about the cell.
   textBox1.Text = "Character: " + cells[0].Character;
   textBox1.Text+= " (" + (char)cells[0].Character + ")" + "\r\n";
   textBox1.Text+= "Raw Character: " + cells[0].RawCharacter;
   textBox1.Text+= " (" + (char)cells[0].RawCharacter + ")" + "\r\n";
   textBox1.Text+= "Background color: " + cells[0].BackColor + "\r\n";
   textBox1.Text+= "Foreground color: " + cells[0].ForeColor + "\r\n";
   textBox1.Text+= "Styles: " + cells[0].Styles;
}

// Use the following code to test the function

// Disable buffer
vt1.BufferRows = 0;

// Clear the display
vt1.Clear();

// Add some dummy data
vt1.Write("\x1b[1mTest \x1b[0mdata\x1b[7m blah \x1b[0m");

// Call the function
ShowCellInfo(0, 3);

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Cell Class | Dart.PowerTCP.Emulation Namespace


Cell.ForeColor Property

Returns the foregrounf color for the cell.

[Visual Basic]
Public ReadOnly Property ForeColor As Color
[C#]
public System.Drawing.Color ForeColor {get;}

Property Value

A System.Drawing.Color value specifying the foreground color for the cell.

Remarks

If no foreground color is specified for the cell, this property will return Color.Empty.

Example

[Visual Basic, C#] The following example demonstrates using the ScrapeCells method to discover info about a cell.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

Private Sub ShowCellInfo(ByVal row As Integer, ByVal col As Integer)
   ' Scrape the row and column specified.
   Dim cells as Cell() = vt1.ScrapeCells(row, col, 1)

   ' Display info about the cell.
   textBox1.Text = "Character: " & cells(0).Character
   textBox1.Text = textBox1.Text & " (" & CChar(cells(0).Character) & ")" & vbCrLf
   textBox1.Text = textBox1.Text & "Raw Character: " & cells(0).RawCharacter
   textBox1.Text = textBox1.Text & " (" & CChar(cells(0).RawCharacter) & ")" & vbCrLf
   textBox1.Text = textBox1.Text & "Background color: " & cells(0).BackColor & vbCrLf
   textBox1.Text = textBox1.Text & "Foreground color: " & cells(0).ForeColor & vbCrLf
   textBox1.Text = textBox1.Text & "Styles: " & cells(0).Styles
End Sub

' Use the following code to test the function

' Disable buffer
vt1.BufferRows = 0

' Clear the display
vt1.Clear()

' Add some dummy data
vt1.Write(Chr(27) + "[1mTest " + Chr(27) + "[0mdata" + Chr(27) + "[7m blah " + Chr(27) + "[0m")

' Call the function
ShowCellInfo(0, 3)
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

private void ShowCellInfo(int row, int col)
{
   // Scrape the row and column specified.
   Cell[] cells = vt1.ScrapeCells(row, col, 1);

   // Display info about the cell.
   textBox1.Text = "Character: " + cells[0].Character;
   textBox1.Text+= " (" + (char)cells[0].Character + ")" + "\r\n";
   textBox1.Text+= "Raw Character: " + cells[0].RawCharacter;
   textBox1.Text+= " (" + (char)cells[0].RawCharacter + ")" + "\r\n";
   textBox1.Text+= "Background color: " + cells[0].BackColor + "\r\n";
   textBox1.Text+= "Foreground color: " + cells[0].ForeColor + "\r\n";
   textBox1.Text+= "Styles: " + cells[0].Styles;
}

// Use the following code to test the function

// Disable buffer
vt1.BufferRows = 0;

// Clear the display
vt1.Clear();

// Add some dummy data
vt1.Write("\x1b[1mTest \x1b[0mdata\x1b[7m blah \x1b[0m");

// Call the function
ShowCellInfo(0, 3);

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Cell Class | Dart.PowerTCP.Emulation Namespace


Cell.RawCharacter Property

Returns the unconverted character within the cell.

[Visual Basic]
Public ReadOnly Property RawCharacter As Byte
[C#]
public byte RawCharacter {get;}

Remarks

While the Vt.Character property may perform a conversion on characters if the special graphics style is applied to the character, this property always returns the character unconverted.

Example

[Visual Basic, C#] The following example demonstrates using the ScrapeCells method to discover info about a cell.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

Private Sub ShowCellInfo(ByVal row As Integer, ByVal col As Integer)
   ' Scrape the row and column specified.
   Dim cells as Cell() = vt1.ScrapeCells(row, col, 1)

   ' Display info about the cell.
   textBox1.Text = "Character: " & cells(0).Character
   textBox1.Text = textBox1.Text & " (" & CChar(cells(0).Character) & ")" & vbCrLf
   textBox1.Text = textBox1.Text & "Raw Character: " & cells(0).RawCharacter
   textBox1.Text = textBox1.Text & " (" & CChar(cells(0).RawCharacter) & ")" & vbCrLf
   textBox1.Text = textBox1.Text & "Background color: " & cells(0).BackColor & vbCrLf
   textBox1.Text = textBox1.Text & "Foreground color: " & cells(0).ForeColor & vbCrLf
   textBox1.Text = textBox1.Text & "Styles: " & cells(0).Styles
End Sub

' Use the following code to test the function

' Disable buffer
vt1.BufferRows = 0

' Clear the display
vt1.Clear()

' Add some dummy data
vt1.Write(Chr(27) + "[1mTest " + Chr(27) + "[0mdata" + Chr(27) + "[7m blah " + Chr(27) + "[0m")

' Call the function
ShowCellInfo(0, 3)
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

private void ShowCellInfo(int row, int col)
{
   // Scrape the row and column specified.
   Cell[] cells = vt1.ScrapeCells(row, col, 1);

   // Display info about the cell.
   textBox1.Text = "Character: " + cells[0].Character;
   textBox1.Text+= " (" + (char)cells[0].Character + ")" + "\r\n";
   textBox1.Text+= "Raw Character: " + cells[0].RawCharacter;
   textBox1.Text+= " (" + (char)cells[0].RawCharacter + ")" + "\r\n";
   textBox1.Text+= "Background color: " + cells[0].BackColor + "\r\n";
   textBox1.Text+= "Foreground color: " + cells[0].ForeColor + "\r\n";
   textBox1.Text+= "Styles: " + cells[0].Styles;
}

// Use the following code to test the function

// Disable buffer
vt1.BufferRows = 0;

// Clear the display
vt1.Clear();

// Add some dummy data
vt1.Write("\x1b[1mTest \x1b[0mdata\x1b[7m blah \x1b[0m");

// Call the function
ShowCellInfo(0, 3);

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Cell Class | Dart.PowerTCP.Emulation Namespace


Cell.Styles Property

Returns Style values representing the styles applied to the cell.

[Visual Basic]
Public ReadOnly Property Styles As Styles
[C#]
public Styles Styles {get;}

Property Value

One or several Styles values specifying the styles applied to the cell.

Remarks

If no style is applied to the cell, this property will return Style.Normal. If multiple styles are applied to the cell, this property will return the flag combination of the Styles. For example if Styles returns 6, then this means the cell has both Style.Bold (2) and Style.Blink(4) applied. Use Style.ToString() to return the values as a comma-delimited list.

Example

[Visual Basic, C#] The following example demonstrates using the ScrapeCells method to discover info about a cell.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

Private Sub ShowCellInfo(ByVal row As Integer, ByVal col As Integer)
   ' Scrape the row and column specified.
   Dim cells as Cell() = vt1.ScrapeCells(row, col, 1)

   ' Display info about the cell.
   textBox1.Text = "Character: " & cells(0).Character
   textBox1.Text = textBox1.Text & " (" & CChar(cells(0).Character) & ")" & vbCrLf
   textBox1.Text = textBox1.Text & "Raw Character: " & cells(0).RawCharacter
   textBox1.Text = textBox1.Text & " (" & CChar(cells(0).RawCharacter) & ")" & vbCrLf
   textBox1.Text = textBox1.Text & "Background color: " & cells(0).BackColor & vbCrLf
   textBox1.Text = textBox1.Text & "Foreground color: " & cells(0).ForeColor & vbCrLf
   textBox1.Text = textBox1.Text & "Styles: " & cells(0).Styles
End Sub

' Use the following code to test the function

' Disable buffer
vt1.BufferRows = 0

' Clear the display
vt1.Clear()

' Add some dummy data
vt1.Write(Chr(27) + "[1mTest " + Chr(27) + "[0mdata" + Chr(27) + "[7m blah " + Chr(27) + "[0m")

' Call the function
ShowCellInfo(0, 3)
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

private void ShowCellInfo(int row, int col)
{
   // Scrape the row and column specified.
   Cell[] cells = vt1.ScrapeCells(row, col, 1);

   // Display info about the cell.
   textBox1.Text = "Character: " + cells[0].Character;
   textBox1.Text+= " (" + (char)cells[0].Character + ")" + "\r\n";
   textBox1.Text+= "Raw Character: " + cells[0].RawCharacter;
   textBox1.Text+= " (" + (char)cells[0].RawCharacter + ")" + "\r\n";
   textBox1.Text+= "Background color: " + cells[0].BackColor + "\r\n";
   textBox1.Text+= "Foreground color: " + cells[0].ForeColor + "\r\n";
   textBox1.Text+= "Styles: " + cells[0].Styles;
}

// Use the following code to test the function

// Disable buffer
vt1.BufferRows = 0;

// Clear the display
vt1.Clear();

// Add some dummy data
vt1.Write("\x1b[1mTest \x1b[0mdata\x1b[7m blah \x1b[0m");

// Call the function
ShowCellInfo(0, 3);

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Cell Class | Dart.PowerTCP.Emulation Namespace


CharSet Enumeration

Enumerates charsets used when creating Font objects.

[Visual Basic]
Public Enum CharSet
[C#]
public enum CharSet

Members

Member Name | Description
Western | ANSI charset. Western Europe, The Americas, Australia/New Zealand.
All | Any (default) charset.
Symbol | Symbol charset. These fonts do not represent characters.
ShiftJis | Japanese charset.
Hangeul | Korean charset.
Gb2312 | Simplified Chinese charset.
ChineseBig5 | Traditional Chinese charset.
Oem | Fonts representing DOS charset, not Windows.
Johab | Korean charset.
Hebrew | Hebrew charset.
Arabic | Arabic charset
Greek | Greek charset.
Turkish | Turkish charset.
Vietnamese | Vietnamese charset.
Thai | Thai charset.
Eastern_European | Eastern Europe charset
Cyrillic | Russian/Cyrillic charset.
Mac | Fonts representing Apple charset.
Baltic | Baltic charset.
Vt | VT charset.

Requirements

Namespace: Dart.PowerTCP.Emulation

Assembly: DocEmulation (in DocEmulation.dll)

See Also

Dart.PowerTCP.Emulation Namespace


CursorKeys Enumeration

Enumerates the values of the Vt.CursorKeys property. The cursor keys can be set up to provide ANSI cursor control or application control.

[Visual Basic]
Public Enum CursorKeys
[C#]
public enum CursorKeys

Example

[Visual Basic, C#] The following example demonstrates setting many of the simple properties to non-default values.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = False

' Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = False

' Set so lines do not wrap if they are too long.
vt1.AutoWrap = True

' Set backcolor to Red
vt1.BackColor = Color.Red

' Disable bell
vt1.Bell = False

' Set Blink Intensity to 40
vt1.BlinkIntensity = 40

' Set bold text color to Blue
vt1.BoldColor = Color.Blue

' Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application

' Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = New System.Drawing.Point(5, 5)

' Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline

' Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow

' "Swap" the foreground and background colors.
vt1.Inverse = True

' Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application

' Echo any typed keys to the display.
vt1.LocalEcho = True

' Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British

' Set Normal Intensity to 80
vt1.NormalIntensity = 80

' Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = New System.Drawing.Size(70, 20)

' Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump

' Change the size of the control to 250 X 100
vt1.Size = New System.Drawing.Size(250, 100)

' Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30"

' Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = False
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = false;

// Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = false;

// Set so lines do not wrap if they are too long.
vt1.AutoWrap = true;

// Set backcolor to Red
vt1.BackColor = Color.Red;

// Disable bell
vt1.Bell = false;

// Set Blink Intensity to 40
vt1.BlinkIntensity = 40;

// Set bold text color to Blue
vt1.BoldColor = Color.Blue;

// Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application;

// Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = new System.Drawing.Point(5, 5);

// Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline;

// Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow;

// "Swap" the foreground and background colors.
vt1.Inverse = true;

// Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application;

// Echo any typed keys to the display.
vt1.LocalEcho = true;

// Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British;

// Set Normal Intensity to 80
vt1.NormalIntensity = 80;

// Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = new System.Drawing.Size(70, 20);

// Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump;

// Change the size of the control to 250 X 100
vt1.Size = new System.Drawing.Size(250, 100);

// Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30";

// Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = false;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Members

Member Name | Description
Normal | Cursor keys generate ANSI cursor control sequences to represent Up, Down, Left, and Right.
Application | Cursor keys generate application control sequences.

Requirements

Namespace: Dart.PowerTCP.Emulation

Assembly: DocEmulation (in DocEmulation.dll)

See Also

Dart.PowerTCP.Emulation Namespace


CursorStyle Enumeration

Enumerates the values of the Vt.CursorStyle property.

[Visual Basic]
Public Enum CursorStyle
[C#]
public enum CursorStyle

Example

[Visual Basic, C#] The following example demonstrates setting many of the simple properties to non-default values.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = False

' Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = False

' Set so lines do not wrap if they are too long.
vt1.AutoWrap = True

' Set backcolor to Red
vt1.BackColor = Color.Red

' Disable bell
vt1.Bell = False

' Set Blink Intensity to 40
vt1.BlinkIntensity = 40

' Set bold text color to Blue
vt1.BoldColor = Color.Blue

' Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application

' Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = New System.Drawing.Point(5, 5)

' Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline

' Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow

' "Swap" the foreground and background colors.
vt1.Inverse = True

' Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application

' Echo any typed keys to the display.
vt1.LocalEcho = True

' Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British

' Set Normal Intensity to 80
vt1.NormalIntensity = 80

' Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = New System.Drawing.Size(70, 20)

' Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump

' Change the size of the control to 250 X 100
vt1.Size = New System.Drawing.Size(250, 100)

' Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30"

' Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = False
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = false;

// Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = false;

// Set so lines do not wrap if they are too long.
vt1.AutoWrap = true;

// Set backcolor to Red
vt1.BackColor = Color.Red;

// Disable bell
vt1.Bell = false;

// Set Blink Intensity to 40
vt1.BlinkIntensity = 40;

// Set bold text color to Blue
vt1.BoldColor = Color.Blue;

// Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application;

// Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = new System.Drawing.Point(5, 5);

// Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline;

// Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow;

// "Swap" the foreground and background colors.
vt1.Inverse = true;

// Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application;

// Echo any typed keys to the display.
vt1.LocalEcho = true;

// Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British;

// Set Normal Intensity to 80
vt1.NormalIntensity = 80;

// Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = new System.Drawing.Size(70, 20);

// Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump;

// Change the size of the control to 250 X 100
vt1.Size = new System.Drawing.Size(250, 100);

// Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30";

// Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = false;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Members

Member Name | Description
Block | Use a block cursor.
Underline | Use an underline cursor.
Invisible | Use an invisible cursor.

Requirements

Namespace: Dart.PowerTCP.Emulation

Assembly: DocEmulation (in DocEmulation.dll)

See Also

Dart.PowerTCP.Emulation Namespace


DataEventArgs Class

Provides data for the KeyPress event.

For a list of all members of this type, see DataEventArgs Members.

System.Object
EventArgs
DataEventArgs

[Visual Basic]
Public Class DataEventArgs
Inherits EventArgs
[C#]
public class DataEventArgs : EventArgs

Remarks

The DataEventArgs specifies the data that was generated as the result of a key press. Often, this will simply be the byte representation of the character that was pressed. However, some single key presses can result in multiple character representations (as a result of internal mapping). You can access the data generated as the result of a key press via the DataEventArgs.Bytes property.

Requirements

Namespace: Dart.PowerTCP.Emulation

Assembly: DocEmulation (in DocEmulation.dll)

See Also

DataEventArgs Members | Dart.PowerTCP.Emulation Namespace


DataEventArgs Members

DataEventArgs overview

Public Instance Constructors

DataEventArgs Constructor Initialize a new instance of DataEventArgs.

Public Instance Properties

Bytes Returns the data that was generated as the result of a key press.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString | Returns the content of Bytes, converted to a string.

See Also

DataEventArgs Class | Dart.PowerTCP.Emulation Namespace


DataEventArgs Constructor

Initialize a new instance of DataEventArgs.

[Visual Basic]
Public Sub New( _
ByVal data As Byte, _
ByVal count As UInt32 _
)
[C#]
public DataEventArgs(
byte data,
uint count
);

See Also

DataEventArgs Class | Dart.PowerTCP.Emulation Namespace


DataEventArgs Properties

The properties of the DataEventArgs class are listed below. For a complete list of DataEventArgs class members, see the DataEventArgs Members topic.

Public Instance Properties

Bytes Returns the data that was generated as the result of a key press.

See Also

DataEventArgs Class | Dart.PowerTCP.Emulation Namespace


DataEventArgs.Bytes Property

Returns the data that was generated as the result of a key press.

[Visual Basic]
Public ReadOnly Property Bytes As Byte()
[C#]
public byte[] Bytes {get;}

Remarks

Often, the data generated by a key press will simply be the byte representation of the character that was pressed. However, some single key presses can result in multiple character representations (as a result of internal mapping). You can access the data generated as the result of a key press via the this property.

See Also

DataEventArgs Class | Dart.PowerTCP.Emulation Namespace


DataEventArgs Methods

The methods of the DataEventArgs class are listed below. For a complete list of DataEventArgs class members, see the DataEventArgs Members topic.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString | Returns the content of Bytes, converted to a string.

See Also

DataEventArgs Class | Dart.PowerTCP.Emulation Namespace


DataEventArgs.ToString Method

Returns the content of Bytes, converted to a string.

[Visual Basic]
Public Function ToString() As String
[C#]
new public string ToString();

Return Value

A string representation of Bytes.

See Also

DataEventArgs Class | Dart.PowerTCP.Emulation Namespace


DataEventHandler Delegate

Represents the method that will handle the event that is raised when key input occurs.

[Visual Basic]
Public Delegate Sub DataEventHandler( _
ByVal sender As Object, _
ByVal e As DataEventArgs _
)
[C#]
public delegate void DataEventHandler(
object sender,
DataEventArgs e
);

Remarks

When you create a DataEventHandler delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate.

Requirements

Namespace: Dart.PowerTCP.Emulation

Assembly: DocEmulation (in DocEmulation.dll)

See Also

Dart.PowerTCP.Emulation Namespace


Font Class

Defines a particular format for text, including font face, size, and style attributes.

For a list of all members of this type, see Font Members.

System.Object
MarshalByRefObject
Font

[Visual Basic]
Public Class Font
Inherits MarshalByRefObject
Implements IComparable
[C#]
public class Font : MarshalByRefObject, IComparable

Remarks

This class differs from the Microsoft .NET Font class (System.Drawing.Font) in that the MS Font class only supports TrueType and OpenType font types, while this class supports TrueType, OpenType, and Raster font types.

Example

[Visual Basic, C#] The following example demonstrates dynamically creating a Font object.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Create a new Font object
Dim f as Dart.PowerTCP.Emulation.Font
f = New Dart.PowerTCP.Emulation.Font("courier", 7.5, FontStyle.Bold + FontStyle.Italic)
vt1.FontEx = f

' Display font info.
textBox1.Text = "Current font" & vbCrLf
textBox1.Text = textBox1.Text & "----------------" & vbCrLf
textBox1.Text = textBox1.Text & "Name: " & vt1.FontEx.Name & vbCrLf
textBox1.Text = textBox1.Text & "Size: " & vt1.FontEx.Size & vbCrLf
textBox1.Text = textBox1.Text & "Bold: " & vt1.FontEx.Bold & vbCrLf
textBox1.Text = textBox1.Text & "Italic: " & vt1.FontEx.Italic & vbCrLf
textBox1.Text = textBox1.Text & "Underline: " & vt1.FontEx.Underline & vbCrLf
textBox1.Text = textBox1.Text & "Strikeout: " & vt1.FontEx.Strikeout & vbCrLf
textBox1.Text = textBox1.Text & "Height: " & vt1.FontEx.Height & vbCrLf
textBox1.Text = textBox1.Text & "Type: " & vt1.FontEx.Type.ToString() & vbCrLF
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Font object
Dart.PowerTCP.Emulation.Font f;
f = new Dart.PowerTCP.Emulation.Font("courier", (float)7.5, FontStyle.Bold | FontStyle.Italic);
vt1.FontEx = f;

// Display font info.
textBox1.Text = "Current font\r\n";
textBox1.Text+= "----------------\r\n";
textBox1.Text+= "Name: " + vt1.FontEx.Name + "\r\n";
textBox1.Text+= "Size: " + vt1.FontEx.Size + "\r\n";
textBox1.Text+= "Bold: " + vt1.FontEx.Bold + "\r\n";
textBox1.Text+= "Italic: " + vt1.FontEx.Italic + "\r\n";
textBox1.Text+= "Underline: " + vt1.FontEx.Underline + "\r\n";
textBox1.Text+= "Strikeout: " + vt1.FontEx.Strikeout + "\r\n";
textBox1.Text+= "Height: " + vt1.FontEx.Height + "\r\n";
textBox1.Text+= "Type: " + vt1.FontEx.Type.ToString() + "\r\n";

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

[Visual Basic, C#] The following example demonstrates using the FontDialog class to set the FontEx propery.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.
' Create a new Dart.PowerTCP.Emulation.FontDialog class
Dim fDialog As New Dart.PowerTCP.Emulation.FontDialog()

' Show the dialog.
If fDialog.ShowDialog() = DialogResult.OK Then
   ' Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font
End If
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Dart.PowerTCP.Emulation.FontDialog class
Dart.PowerTCP.Emulation.FontDialog fDialog = new Dart.PowerTCP.Emulation.FontDialog();

// Show the dialog.
if(fDialog.ShowDialog() == DialogResult.OK)
{
   // Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font;
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: Dart.PowerTCP.Emulation

Assembly: DocEmulation (in DocEmulation.dll)

See Also

Font Members | Dart.PowerTCP.Emulation Namespace


Font Members

Font overview

Public Instance Constructors

Font Overloaded. Initializes a new instance of the Font class.

Public Instance Properties

Bold | Gets a value that indicates whether this Font object is bold.
CharSet | Indicates value of the potential characters.
Height | Gets the height of this Font object.
Italic | Gets a value that indicates whether this Font object is italic.
Name | Gets the face name of this Font object.
Size | Gets the em-size of this Font object in design units.
Strikeout | Gets a value that indicates whether this Font object specifies a horizontal line through the font.
Type | Gets the font type of this Font object.
Underline | Gets a value that indicates whether this Font object is underlined.

Public Instance Methods

CompareTo | Compares this instance with a specified Object.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
ToHfont | Returns a handle to this Font object.
ToString | Returns a human-readable string representation of this Font object.

See Also

Font Class | Dart.PowerTCP.Emulation Namespace


Font Constructor

Initializes a new Font object that uses the handle of an existing Font object.

Overload List

Initializes a new Font object that uses the specified existing Font object and FontStyle enumeration.

public Font(Font,FontStyle);

Initializes a new Font object that uses the specified attributes.

public Font(FontFamily,float);

Initializes a new Font object that uses the specified attributes.

public Font(FontFamily,float,FontStyle);

Initializes a new Font object that uses the specified attributes.

public Font(FontFamily,float,FontStyle,CharSet);

Initializes a new Font object that uses the handle of an existing Font object.

public Font(IntPtr);

Initializes a new Font object that uses the specified attributes.

public Font(string,float);

Initializes a new Font object that uses the specified attributes.

public Font(string,float,FontStyle);

Initializes a new Font object that uses the specified attributes.

public Font(string,float,FontStyle,CharSet);

See Also

Font Class | Dart.PowerTCP.Emulation Namespace


Font Constructor (IntPtr)

Initializes a new Font object that uses the handle of an existing Font object.

[Visual Basic]
Overloads Public Sub New( _
ByVal font As IntPtr _
)
[C#]
public Font(
IntPtr font
);

Parameters

font
The handle of an existing Font object.

See Also

Font Class | Dart.PowerTCP.Emulation Namespace | Font Constructor Overload List


Font Constructor (Font, FontStyle)

Initializes a new Font object that uses the specified existing Font object and FontStyle enumeration.

[Visual Basic]
Overloads Public Sub New( _
ByVal prototype As Font, _
ByVal style As FontStyle _
)
[C#]
public Font(
Font prototype,
FontStyle style
);

Parameters

prototype
The existing Font object from which to create the new Font object.
style
The FontStyle enumeration to apply to the new Font object. Multiple values of the FontStyle enumeration can be combined with the OR operator.

See Also

Font Class | Dart.PowerTCP.Emulation Namespace | Font Constructor Overload List


Font Constructor (FontFamily, Single)

Initializes a new Font object that uses the specified attributes.

[Visual Basic]
Overloads Public Sub New( _
ByVal family As FontFamily, _
ByVal emSize As Single _
)
[C#]
public Font(
FontFamily family,
float emSize
);

Parameters

family
The FontFamily object of the new Font object
emSize
The size of the new Font object.

See Also

Font Class | Dart.PowerTCP.Emulation Namespace | Font Constructor Overload List


Font Constructor (String, Single)

Initializes a new Font object that uses the specified attributes.

[Visual Basic]
Overloads Public Sub New( _
ByVal familyName As String, _
ByVal emSize As Single _
)
[C#]
public Font(
string familyName,
float emSize
);

Parameters

familyName
A string representation of the FontFamily object for the new Font object.
emSize
The size of the new Font object.

See Also

Font Class | Dart.PowerTCP.Emulation Namespace | Font Constructor Overload List


Font Constructor (FontFamily, Single, FontStyle)

Initializes a new Font object that uses the specified attributes.

[Visual Basic]
Overloads Public Sub New( _
ByVal family As FontFamily, _
ByVal emSize As Single, _
ByVal style As FontStyle _
)
[C#]
public Font(
FontFamily family,
float emSize,
FontStyle style
);

Parameters

family
The FontFamily object of the new Font object.
emSize
The size of the new Font object.
style
The FontStyle enumeration to be applied to the new Font object.

See Also

Font Class | Dart.PowerTCP.Emulation Namespace | Font Constructor Overload List


Font Constructor (String, Single, FontStyle)

Initializes a new Font object that uses the specified attributes.

[Visual Basic]
Overloads Public Sub New( _
ByVal familyName As String, _
ByVal emSize As Single, _
ByVal style As FontStyle _
)
[C#]
public Font(
string familyName,
float emSize,
FontStyle style
);

Parameters

familyName
A string representation of the FontFamily object for the new Font object.
emSize
The size of the new Font object.
style
The FontStyle enumeration to be applied to the new Font object.

See Also

Font Class | Dart.PowerTCP.Emulation Namespace | Font Constructor Overload List


Font Constructor (FontFamily, Single, FontStyle, CharSet)

Initializes a new Font object that uses the specified attributes.

[Visual Basic]
Overloads Public Sub New( _
ByVal family As FontFamily, _
ByVal emSize As Single, _
ByVal style As FontStyle, _
ByVal charset As CharSet _
)
[C#]
public Font(
FontFamily family,
float emSize,
FontStyle style,
CharSet charset
);

Parameters

family
The FontFamily object of the new Font object.
emSize
The size of the new Font object.
style
The FontStyle enumeration to be applied to the new Font object.
charset
The character set of the font.

See Also

Font Class | Dart.PowerTCP.Emulation Namespace | Font Constructor Overload List


Font Constructor (String, Single, FontStyle, CharSet)

Initializes a new Font object that uses the specified attributes.

[Visual Basic]
Overloads Public Sub New( _
ByVal familyName As String, _
ByVal emSize As Single, _
ByVal style As FontStyle, _
ByVal charset As CharSet _
)
[C#]
public Font(
string familyName,
float emSize,
FontStyle style,
CharSet charset
);

Parameters

familyName
A string representation of the FontFamily object for the new Font object.
emSize
The size of the new Font object.
style
The FontStyle enumeration to be applied to the new Font object.
charset
The character set of the font.

See Also

Font Class | Dart.PowerTCP.Emulation Namespace | Font Constructor Overload List


Font Properties

The properties of the Font class are listed below. For a complete list of Font class members, see the Font Members topic.

Public Instance Properties

Bold | Gets a value that indicates whether this Font object is bold.
CharSet | Indicates value of the potential characters.
Height | Gets the height of this Font object.
Italic | Gets a value that indicates whether this Font object is italic.
Name | Gets the face name of this Font object.
Size | Gets the em-size of this Font object in design units.
Strikeout | Gets a value that indicates whether this Font object specifies a horizontal line through the font.
Type | Gets the font type of this Font object.
Underline | Gets a value that indicates whether this Font object is underlined.

See Also

Font Class | Dart.PowerTCP.Emulation Namespace


Font.Bold Property

Gets a value that indicates whether this Font object is bold.

[Visual Basic]
Public ReadOnly Property Bold As Boolean
[C#]
public bool Bold {get;}

Property Value

This property returns true if this Font object is bold; otherwise, false.

Example

[Visual Basic, C#] The following example demonstrates dynamically creating a Font object.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Create a new Font object
Dim f as Dart.PowerTCP.Emulation.Font
f = New Dart.PowerTCP.Emulation.Font("courier", 7.5, FontStyle.Bold + FontStyle.Italic)
vt1.FontEx = f

' Display font info.
textBox1.Text = "Current font" & vbCrLf
textBox1.Text = textBox1.Text & "----------------" & vbCrLf
textBox1.Text = textBox1.Text & "Name: " & vt1.FontEx.Name & vbCrLf
textBox1.Text = textBox1.Text & "Size: " & vt1.FontEx.Size & vbCrLf
textBox1.Text = textBox1.Text & "Bold: " & vt1.FontEx.Bold & vbCrLf
textBox1.Text = textBox1.Text & "Italic: " & vt1.FontEx.Italic & vbCrLf
textBox1.Text = textBox1.Text & "Underline: " & vt1.FontEx.Underline & vbCrLf
textBox1.Text = textBox1.Text & "Strikeout: " & vt1.FontEx.Strikeout & vbCrLf
textBox1.Text = textBox1.Text & "Height: " & vt1.FontEx.Height & vbCrLf
textBox1.Text = textBox1.Text & "Type: " & vt1.FontEx.Type.ToString() & vbCrLF
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Font object
Dart.PowerTCP.Emulation.Font f;
f = new Dart.PowerTCP.Emulation.Font("courier", (float)7.5, FontStyle.Bold | FontStyle.Italic);
vt1.FontEx = f;

// Display font info.
textBox1.Text = "Current font\r\n";
textBox1.Text+= "----------------\r\n";
textBox1.Text+= "Name: " + vt1.FontEx.Name + "\r\n";
textBox1.Text+= "Size: " + vt1.FontEx.Size + "\r\n";
textBox1.Text+= "Bold: " + vt1.FontEx.Bold + "\r\n";
textBox1.Text+= "Italic: " + vt1.FontEx.Italic + "\r\n";
textBox1.Text+= "Underline: " + vt1.FontEx.Underline + "\r\n";
textBox1.Text+= "Strikeout: " + vt1.FontEx.Strikeout + "\r\n";
textBox1.Text+= "Height: " + vt1.FontEx.Height + "\r\n";
textBox1.Text+= "Type: " + vt1.FontEx.Type.ToString() + "\r\n";

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

[Visual Basic, C#] The following example demonstrates using the FontDialog class to set the FontEx propery.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.
' Create a new Dart.PowerTCP.Emulation.FontDialog class
Dim fDialog As New Dart.PowerTCP.Emulation.FontDialog()

' Show the dialog.
If fDialog.ShowDialog() = DialogResult.OK Then
   ' Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font
End If
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Dart.PowerTCP.Emulation.FontDialog class
Dart.PowerTCP.Emulation.FontDialog fDialog = new Dart.PowerTCP.Emulation.FontDialog();

// Show the dialog.
if(fDialog.ShowDialog() == DialogResult.OK)
{
   // Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font;
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Font Class | Dart.PowerTCP.Emulation Namespace


Font.CharSet Property

Indicates value of the potential characters.

[Visual Basic]
Public ReadOnly Property CharSet As CharSet
[C#]
public CharSet CharSet {get;}

Property Value

A CharSet value identifying the character set of the font.

Example

[Visual Basic, C#] The following example demonstrates dynamically creating a Font object.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Create a new Font object
Dim f as Dart.PowerTCP.Emulation.Font
f = New Dart.PowerTCP.Emulation.Font("courier", 7.5, FontStyle.Bold + FontStyle.Italic)
vt1.FontEx = f

' Display font info.
textBox1.Text = "Current font" & vbCrLf
textBox1.Text = textBox1.Text & "----------------" & vbCrLf
textBox1.Text = textBox1.Text & "Name: " & vt1.FontEx.Name & vbCrLf
textBox1.Text = textBox1.Text & "Size: " & vt1.FontEx.Size & vbCrLf
textBox1.Text = textBox1.Text & "Bold: " & vt1.FontEx.Bold & vbCrLf
textBox1.Text = textBox1.Text & "Italic: " & vt1.FontEx.Italic & vbCrLf
textBox1.Text = textBox1.Text & "Underline: " & vt1.FontEx.Underline & vbCrLf
textBox1.Text = textBox1.Text & "Strikeout: " & vt1.FontEx.Strikeout & vbCrLf
textBox1.Text = textBox1.Text & "Height: " & vt1.FontEx.Height & vbCrLf
textBox1.Text = textBox1.Text & "Type: " & vt1.FontEx.Type.ToString() & vbCrLF
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Font object
Dart.PowerTCP.Emulation.Font f;
f = new Dart.PowerTCP.Emulation.Font("courier", (float)7.5, FontStyle.Bold | FontStyle.Italic);
vt1.FontEx = f;

// Display font info.
textBox1.Text = "Current font\r\n";
textBox1.Text+= "----------------\r\n";
textBox1.Text+= "Name: " + vt1.FontEx.Name + "\r\n";
textBox1.Text+= "Size: " + vt1.FontEx.Size + "\r\n";
textBox1.Text+= "Bold: " + vt1.FontEx.Bold + "\r\n";
textBox1.Text+= "Italic: " + vt1.FontEx.Italic + "\r\n";
textBox1.Text+= "Underline: " + vt1.FontEx.Underline + "\r\n";
textBox1.Text+= "Strikeout: " + vt1.FontEx.Strikeout + "\r\n";
textBox1.Text+= "Height: " + vt1.FontEx.Height + "\r\n";
textBox1.Text+= "Type: " + vt1.FontEx.Type.ToString() + "\r\n";

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

[Visual Basic, C#] The following example demonstrates using the FontDialog class to set the FontEx propery.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.
' Create a new Dart.PowerTCP.Emulation.FontDialog class
Dim fDialog As New Dart.PowerTCP.Emulation.FontDialog()

' Show the dialog.
If fDialog.ShowDialog() = DialogResult.OK Then
   ' Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font
End If
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Dart.PowerTCP.Emulation.FontDialog class
Dart.PowerTCP.Emulation.FontDialog fDialog = new Dart.PowerTCP.Emulation.FontDialog();

// Show the dialog.
if(fDialog.ShowDialog() == DialogResult.OK)
{
   // Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font;
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Font Class | Dart.PowerTCP.Emulation Namespace


Font.Height Property

Gets the height of this Font object.

[Visual Basic]
Public ReadOnly Property Height As Integer
[C#]
public int Height {get;}

Property Value

The height of this Font object in current graphics units.

Example

[Visual Basic, C#] The following example demonstrates dynamically creating a Font object.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Create a new Font object
Dim f as Dart.PowerTCP.Emulation.Font
f = New Dart.PowerTCP.Emulation.Font("courier", 7.5, FontStyle.Bold + FontStyle.Italic)
vt1.FontEx = f

' Display font info.
textBox1.Text = "Current font" & vbCrLf
textBox1.Text = textBox1.Text & "----------------" & vbCrLf
textBox1.Text = textBox1.Text & "Name: " & vt1.FontEx.Name & vbCrLf
textBox1.Text = textBox1.Text & "Size: " & vt1.FontEx.Size & vbCrLf
textBox1.Text = textBox1.Text & "Bold: " & vt1.FontEx.Bold & vbCrLf
textBox1.Text = textBox1.Text & "Italic: " & vt1.FontEx.Italic & vbCrLf
textBox1.Text = textBox1.Text & "Underline: " & vt1.FontEx.Underline & vbCrLf
textBox1.Text = textBox1.Text & "Strikeout: " & vt1.FontEx.Strikeout & vbCrLf
textBox1.Text = textBox1.Text & "Height: " & vt1.FontEx.Height & vbCrLf
textBox1.Text = textBox1.Text & "Type: " & vt1.FontEx.Type.ToString() & vbCrLF
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Font object
Dart.PowerTCP.Emulation.Font f;
f = new Dart.PowerTCP.Emulation.Font("courier", (float)7.5, FontStyle.Bold | FontStyle.Italic);
vt1.FontEx = f;

// Display font info.
textBox1.Text = "Current font\r\n";
textBox1.Text+= "----------------\r\n";
textBox1.Text+= "Name: " + vt1.FontEx.Name + "\r\n";
textBox1.Text+= "Size: " + vt1.FontEx.Size + "\r\n";
textBox1.Text+= "Bold: " + vt1.FontEx.Bold + "\r\n";
textBox1.Text+= "Italic: " + vt1.FontEx.Italic + "\r\n";
textBox1.Text+= "Underline: " + vt1.FontEx.Underline + "\r\n";
textBox1.Text+= "Strikeout: " + vt1.FontEx.Strikeout + "\r\n";
textBox1.Text+= "Height: " + vt1.FontEx.Height + "\r\n";
textBox1.Text+= "Type: " + vt1.FontEx.Type.ToString() + "\r\n";

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

[Visual Basic, C#] The following example demonstrates using the FontDialog class to set the FontEx propery.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.
' Create a new Dart.PowerTCP.Emulation.FontDialog class
Dim fDialog As New Dart.PowerTCP.Emulation.FontDialog()

' Show the dialog.
If fDialog.ShowDialog() = DialogResult.OK Then
   ' Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font
End If
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Dart.PowerTCP.Emulation.FontDialog class
Dart.PowerTCP.Emulation.FontDialog fDialog = new Dart.PowerTCP.Emulation.FontDialog();

// Show the dialog.
if(fDialog.ShowDialog() == DialogResult.OK)
{
   // Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font;
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Font Class | Dart.PowerTCP.Emulation Namespace


Font.Italic Property

Gets a value that indicates whether this Font object is italic.

[Visual Basic]
Public ReadOnly Property Italic As Boolean
[C#]
public bool Italic {get;}

Property Value

This property returns true if this Font object is italic; otherwise, false.

Example

[Visual Basic, C#] The following example demonstrates dynamically creating a Font object.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Create a new Font object
Dim f as Dart.PowerTCP.Emulation.Font
f = New Dart.PowerTCP.Emulation.Font("courier", 7.5, FontStyle.Bold + FontStyle.Italic)
vt1.FontEx = f

' Display font info.
textBox1.Text = "Current font" & vbCrLf
textBox1.Text = textBox1.Text & "----------------" & vbCrLf
textBox1.Text = textBox1.Text & "Name: " & vt1.FontEx.Name & vbCrLf
textBox1.Text = textBox1.Text & "Size: " & vt1.FontEx.Size & vbCrLf
textBox1.Text = textBox1.Text & "Bold: " & vt1.FontEx.Bold & vbCrLf
textBox1.Text = textBox1.Text & "Italic: " & vt1.FontEx.Italic & vbCrLf
textBox1.Text = textBox1.Text & "Underline: " & vt1.FontEx.Underline & vbCrLf
textBox1.Text = textBox1.Text & "Strikeout: " & vt1.FontEx.Strikeout & vbCrLf
textBox1.Text = textBox1.Text & "Height: " & vt1.FontEx.Height & vbCrLf
textBox1.Text = textBox1.Text & "Type: " & vt1.FontEx.Type.ToString() & vbCrLF
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Font object
Dart.PowerTCP.Emulation.Font f;
f = new Dart.PowerTCP.Emulation.Font("courier", (float)7.5, FontStyle.Bold | FontStyle.Italic);
vt1.FontEx = f;

// Display font info.
textBox1.Text = "Current font\r\n";
textBox1.Text+= "----------------\r\n";
textBox1.Text+= "Name: " + vt1.FontEx.Name + "\r\n";
textBox1.Text+= "Size: " + vt1.FontEx.Size + "\r\n";
textBox1.Text+= "Bold: " + vt1.FontEx.Bold + "\r\n";
textBox1.Text+= "Italic: " + vt1.FontEx.Italic + "\r\n";
textBox1.Text+= "Underline: " + vt1.FontEx.Underline + "\r\n";
textBox1.Text+= "Strikeout: " + vt1.FontEx.Strikeout + "\r\n";
textBox1.Text+= "Height: " + vt1.FontEx.Height + "\r\n";
textBox1.Text+= "Type: " + vt1.FontEx.Type.ToString() + "\r\n";

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

[Visual Basic, C#] The following example demonstrates using the FontDialog class to set the FontEx propery.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.
' Create a new Dart.PowerTCP.Emulation.FontDialog class
Dim fDialog As New Dart.PowerTCP.Emulation.FontDialog()

' Show the dialog.
If fDialog.ShowDialog() = DialogResult.OK Then
   ' Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font
End If
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Dart.PowerTCP.Emulation.FontDialog class
Dart.PowerTCP.Emulation.FontDialog fDialog = new Dart.PowerTCP.Emulation.FontDialog();

// Show the dialog.
if(fDialog.ShowDialog() == DialogResult.OK)
{
   // Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font;
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Font Class | Dart.PowerTCP.Emulation Namespace


Font.Name Property

Gets the face name of this Font object.

[Visual Basic]
Public ReadOnly Property Name As String
[C#]
public string Name {get;}

Property Value

A string representation of the face name of this Font object.

Example

[Visual Basic, C#] The following example demonstrates dynamically creating a Font object.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Create a new Font object
Dim f as Dart.PowerTCP.Emulation.Font
f = New Dart.PowerTCP.Emulation.Font("courier", 7.5, FontStyle.Bold + FontStyle.Italic)
vt1.FontEx = f

' Display font info.
textBox1.Text = "Current font" & vbCrLf
textBox1.Text = textBox1.Text & "----------------" & vbCrLf
textBox1.Text = textBox1.Text & "Name: " & vt1.FontEx.Name & vbCrLf
textBox1.Text = textBox1.Text & "Size: " & vt1.FontEx.Size & vbCrLf
textBox1.Text = textBox1.Text & "Bold: " & vt1.FontEx.Bold & vbCrLf
textBox1.Text = textBox1.Text & "Italic: " & vt1.FontEx.Italic & vbCrLf
textBox1.Text = textBox1.Text & "Underline: " & vt1.FontEx.Underline & vbCrLf
textBox1.Text = textBox1.Text & "Strikeout: " & vt1.FontEx.Strikeout & vbCrLf
textBox1.Text = textBox1.Text & "Height: " & vt1.FontEx.Height & vbCrLf
textBox1.Text = textBox1.Text & "Type: " & vt1.FontEx.Type.ToString() & vbCrLF
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Font object
Dart.PowerTCP.Emulation.Font f;
f = new Dart.PowerTCP.Emulation.Font("courier", (float)7.5, FontStyle.Bold | FontStyle.Italic);
vt1.FontEx = f;

// Display font info.
textBox1.Text = "Current font\r\n";
textBox1.Text+= "----------------\r\n";
textBox1.Text+= "Name: " + vt1.FontEx.Name + "\r\n";
textBox1.Text+= "Size: " + vt1.FontEx.Size + "\r\n";
textBox1.Text+= "Bold: " + vt1.FontEx.Bold + "\r\n";
textBox1.Text+= "Italic: " + vt1.FontEx.Italic + "\r\n";
textBox1.Text+= "Underline: " + vt1.FontEx.Underline + "\r\n";
textBox1.Text+= "Strikeout: " + vt1.FontEx.Strikeout + "\r\n";
textBox1.Text+= "Height: " + vt1.FontEx.Height + "\r\n";
textBox1.Text+= "Type: " + vt1.FontEx.Type.ToString() + "\r\n";

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

[Visual Basic, C#] The following example demonstrates using the FontDialog class to set the FontEx propery.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.
' Create a new Dart.PowerTCP.Emulation.FontDialog class
Dim fDialog As New Dart.PowerTCP.Emulation.FontDialog()

' Show the dialog.
If fDialog.ShowDialog() = DialogResult.OK Then
   ' Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font
End If
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Dart.PowerTCP.Emulation.FontDialog class
Dart.PowerTCP.Emulation.FontDialog fDialog = new Dart.PowerTCP.Emulation.FontDialog();

// Show the dialog.
if(fDialog.ShowDialog() == DialogResult.OK)
{
   // Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font;
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Font Class | Dart.PowerTCP.Emulation Namespace


Font.Size Property

Gets the em-size of this Font object in design units.

[Visual Basic]
Public ReadOnly Property Size As Single
[C#]
public float Size {get;}

Property Value

The em-size of this Font object in design units.

Example

[Visual Basic, C#] The following example demonstrates dynamically creating a Font object.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Create a new Font object
Dim f as Dart.PowerTCP.Emulation.Font
f = New Dart.PowerTCP.Emulation.Font("courier", 7.5, FontStyle.Bold + FontStyle.Italic)
vt1.FontEx = f

' Display font info.
textBox1.Text = "Current font" & vbCrLf
textBox1.Text = textBox1.Text & "----------------" & vbCrLf
textBox1.Text = textBox1.Text & "Name: " & vt1.FontEx.Name & vbCrLf
textBox1.Text = textBox1.Text & "Size: " & vt1.FontEx.Size & vbCrLf
textBox1.Text = textBox1.Text & "Bold: " & vt1.FontEx.Bold & vbCrLf
textBox1.Text = textBox1.Text & "Italic: " & vt1.FontEx.Italic & vbCrLf
textBox1.Text = textBox1.Text & "Underline: " & vt1.FontEx.Underline & vbCrLf
textBox1.Text = textBox1.Text & "Strikeout: " & vt1.FontEx.Strikeout & vbCrLf
textBox1.Text = textBox1.Text & "Height: " & vt1.FontEx.Height & vbCrLf
textBox1.Text = textBox1.Text & "Type: " & vt1.FontEx.Type.ToString() & vbCrLF
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Font object
Dart.PowerTCP.Emulation.Font f;
f = new Dart.PowerTCP.Emulation.Font("courier", (float)7.5, FontStyle.Bold | FontStyle.Italic);
vt1.FontEx = f;

// Display font info.
textBox1.Text = "Current font\r\n";
textBox1.Text+= "----------------\r\n";
textBox1.Text+= "Name: " + vt1.FontEx.Name + "\r\n";
textBox1.Text+= "Size: " + vt1.FontEx.Size + "\r\n";
textBox1.Text+= "Bold: " + vt1.FontEx.Bold + "\r\n";
textBox1.Text+= "Italic: " + vt1.FontEx.Italic + "\r\n";
textBox1.Text+= "Underline: " + vt1.FontEx.Underline + "\r\n";
textBox1.Text+= "Strikeout: " + vt1.FontEx.Strikeout + "\r\n";
textBox1.Text+= "Height: " + vt1.FontEx.Height + "\r\n";
textBox1.Text+= "Type: " + vt1.FontEx.Type.ToString() + "\r\n";

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

[Visual Basic, C#] The following example demonstrates using the FontDialog class to set the FontEx propery.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.
' Create a new Dart.PowerTCP.Emulation.FontDialog class
Dim fDialog As New Dart.PowerTCP.Emulation.FontDialog()

' Show the dialog.
If fDialog.ShowDialog() = DialogResult.OK Then
   ' Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font
End If
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Dart.PowerTCP.Emulation.FontDialog class
Dart.PowerTCP.Emulation.FontDialog fDialog = new Dart.PowerTCP.Emulation.FontDialog();

// Show the dialog.
if(fDialog.ShowDialog() == DialogResult.OK)
{
   // Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font;
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Font Class | Dart.PowerTCP.Emulation Namespace


Font.Strikeout Property

Gets a value that indicates whether this Font object specifies a horizontal line through the font.

[Visual Basic]
Public ReadOnly Property Strikeout As Boolean
[C#]
public bool Strikeout {get;}

Property Value

This property is true if this Font object has a horizontal line through it; otherwise, false.

Example

[Visual Basic, C#] The following example demonstrates dynamically creating a Font object.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Create a new Font object
Dim f as Dart.PowerTCP.Emulation.Font
f = New Dart.PowerTCP.Emulation.Font("courier", 7.5, FontStyle.Bold + FontStyle.Italic)
vt1.FontEx = f

' Display font info.
textBox1.Text = "Current font" & vbCrLf
textBox1.Text = textBox1.Text & "----------------" & vbCrLf
textBox1.Text = textBox1.Text & "Name: " & vt1.FontEx.Name & vbCrLf
textBox1.Text = textBox1.Text & "Size: " & vt1.FontEx.Size & vbCrLf
textBox1.Text = textBox1.Text & "Bold: " & vt1.FontEx.Bold & vbCrLf
textBox1.Text = textBox1.Text & "Italic: " & vt1.FontEx.Italic & vbCrLf
textBox1.Text = textBox1.Text & "Underline: " & vt1.FontEx.Underline & vbCrLf
textBox1.Text = textBox1.Text & "Strikeout: " & vt1.FontEx.Strikeout & vbCrLf
textBox1.Text = textBox1.Text & "Height: " & vt1.FontEx.Height & vbCrLf
textBox1.Text = textBox1.Text & "Type: " & vt1.FontEx.Type.ToString() & vbCrLF
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Font object
Dart.PowerTCP.Emulation.Font f;
f = new Dart.PowerTCP.Emulation.Font("courier", (float)7.5, FontStyle.Bold | FontStyle.Italic);
vt1.FontEx = f;

// Display font info.
textBox1.Text = "Current font\r\n";
textBox1.Text+= "----------------\r\n";
textBox1.Text+= "Name: " + vt1.FontEx.Name + "\r\n";
textBox1.Text+= "Size: " + vt1.FontEx.Size + "\r\n";
textBox1.Text+= "Bold: " + vt1.FontEx.Bold + "\r\n";
textBox1.Text+= "Italic: " + vt1.FontEx.Italic + "\r\n";
textBox1.Text+= "Underline: " + vt1.FontEx.Underline + "\r\n";
textBox1.Text+= "Strikeout: " + vt1.FontEx.Strikeout + "\r\n";
textBox1.Text+= "Height: " + vt1.FontEx.Height + "\r\n";
textBox1.Text+= "Type: " + vt1.FontEx.Type.ToString() + "\r\n";

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

[Visual Basic, C#] The following example demonstrates using the FontDialog class to set the FontEx propery.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.
' Create a new Dart.PowerTCP.Emulation.FontDialog class
Dim fDialog As New Dart.PowerTCP.Emulation.FontDialog()

' Show the dialog.
If fDialog.ShowDialog() = DialogResult.OK Then
   ' Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font
End If
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Dart.PowerTCP.Emulation.FontDialog class
Dart.PowerTCP.Emulation.FontDialog fDialog = new Dart.PowerTCP.Emulation.FontDialog();

// Show the dialog.
if(fDialog.ShowDialog() == DialogResult.OK)
{
   // Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font;
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Font Class | Dart.PowerTCP.Emulation Namespace


Font.Type Property

Gets the font type of this Font object.

[Visual Basic]
Public ReadOnly Property Type As FontType
[C#]
public FontType Type {get;}

Property Value

A Dart.PowerTCP.Emulation.FontType value specifying the font type.

Example

[Visual Basic, C#] The following example demonstrates dynamically creating a Font object.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Create a new Font object
Dim f as Dart.PowerTCP.Emulation.Font
f = New Dart.PowerTCP.Emulation.Font("courier", 7.5, FontStyle.Bold + FontStyle.Italic)
vt1.FontEx = f

' Display font info.
textBox1.Text = "Current font" & vbCrLf
textBox1.Text = textBox1.Text & "----------------" & vbCrLf
textBox1.Text = textBox1.Text & "Name: " & vt1.FontEx.Name & vbCrLf
textBox1.Text = textBox1.Text & "Size: " & vt1.FontEx.Size & vbCrLf
textBox1.Text = textBox1.Text & "Bold: " & vt1.FontEx.Bold & vbCrLf
textBox1.Text = textBox1.Text & "Italic: " & vt1.FontEx.Italic & vbCrLf
textBox1.Text = textBox1.Text & "Underline: " & vt1.FontEx.Underline & vbCrLf
textBox1.Text = textBox1.Text & "Strikeout: " & vt1.FontEx.Strikeout & vbCrLf
textBox1.Text = textBox1.Text & "Height: " & vt1.FontEx.Height & vbCrLf
textBox1.Text = textBox1.Text & "Type: " & vt1.FontEx.Type.ToString() & vbCrLF
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Font object
Dart.PowerTCP.Emulation.Font f;
f = new Dart.PowerTCP.Emulation.Font("courier", (float)7.5, FontStyle.Bold | FontStyle.Italic);
vt1.FontEx = f;

// Display font info.
textBox1.Text = "Current font\r\n";
textBox1.Text+= "----------------\r\n";
textBox1.Text+= "Name: " + vt1.FontEx.Name + "\r\n";
textBox1.Text+= "Size: " + vt1.FontEx.Size + "\r\n";
textBox1.Text+= "Bold: " + vt1.FontEx.Bold + "\r\n";
textBox1.Text+= "Italic: " + vt1.FontEx.Italic + "\r\n";
textBox1.Text+= "Underline: " + vt1.FontEx.Underline + "\r\n";
textBox1.Text+= "Strikeout: " + vt1.FontEx.Strikeout + "\r\n";
textBox1.Text+= "Height: " + vt1.FontEx.Height + "\r\n";
textBox1.Text+= "Type: " + vt1.FontEx.Type.ToString() + "\r\n";

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

[Visual Basic, C#] The following example demonstrates using the FontDialog class to set the FontEx propery.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.
' Create a new Dart.PowerTCP.Emulation.FontDialog class
Dim fDialog As New Dart.PowerTCP.Emulation.FontDialog()

' Show the dialog.
If fDialog.ShowDialog() = DialogResult.OK Then
   ' Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font
End If
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Dart.PowerTCP.Emulation.FontDialog class
Dart.PowerTCP.Emulation.FontDialog fDialog = new Dart.PowerTCP.Emulation.FontDialog();

// Show the dialog.
if(fDialog.ShowDialog() == DialogResult.OK)
{
   // Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font;
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Font Class | Dart.PowerTCP.Emulation Namespace


Font.Underline Property

Gets a value that indicates whether this Font object is underlined.

[Visual Basic]
Public ReadOnly Property Underline As Boolean
[C#]
public bool Underline {get;}

Property Value

This property returns true if this Font object is underlined; otherwise, false.

Example

[Visual Basic, C#] The following example demonstrates dynamically creating a Font object.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Create a new Font object
Dim f as Dart.PowerTCP.Emulation.Font
f = New Dart.PowerTCP.Emulation.Font("courier", 7.5, FontStyle.Bold + FontStyle.Italic)
vt1.FontEx = f

' Display font info.
textBox1.Text = "Current font" & vbCrLf
textBox1.Text = textBox1.Text & "----------------" & vbCrLf
textBox1.Text = textBox1.Text & "Name: " & vt1.FontEx.Name & vbCrLf
textBox1.Text = textBox1.Text & "Size: " & vt1.FontEx.Size & vbCrLf
textBox1.Text = textBox1.Text & "Bold: " & vt1.FontEx.Bold & vbCrLf
textBox1.Text = textBox1.Text & "Italic: " & vt1.FontEx.Italic & vbCrLf
textBox1.Text = textBox1.Text & "Underline: " & vt1.FontEx.Underline & vbCrLf
textBox1.Text = textBox1.Text & "Strikeout: " & vt1.FontEx.Strikeout & vbCrLf
textBox1.Text = textBox1.Text & "Height: " & vt1.FontEx.Height & vbCrLf
textBox1.Text = textBox1.Text & "Type: " & vt1.FontEx.Type.ToString() & vbCrLF
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Font object
Dart.PowerTCP.Emulation.Font f;
f = new Dart.PowerTCP.Emulation.Font("courier", (float)7.5, FontStyle.Bold | FontStyle.Italic);
vt1.FontEx = f;

// Display font info.
textBox1.Text = "Current font\r\n";
textBox1.Text+= "----------------\r\n";
textBox1.Text+= "Name: " + vt1.FontEx.Name + "\r\n";
textBox1.Text+= "Size: " + vt1.FontEx.Size + "\r\n";
textBox1.Text+= "Bold: " + vt1.FontEx.Bold + "\r\n";
textBox1.Text+= "Italic: " + vt1.FontEx.Italic + "\r\n";
textBox1.Text+= "Underline: " + vt1.FontEx.Underline + "\r\n";
textBox1.Text+= "Strikeout: " + vt1.FontEx.Strikeout + "\r\n";
textBox1.Text+= "Height: " + vt1.FontEx.Height + "\r\n";
textBox1.Text+= "Type: " + vt1.FontEx.Type.ToString() + "\r\n";

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

[Visual Basic, C#] The following example demonstrates using the FontDialog class to set the FontEx propery.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.
' Create a new Dart.PowerTCP.Emulation.FontDialog class
Dim fDialog As New Dart.PowerTCP.Emulation.FontDialog()

' Show the dialog.
If fDialog.ShowDialog() = DialogResult.OK Then
   ' Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font
End If
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Dart.PowerTCP.Emulation.FontDialog class
Dart.PowerTCP.Emulation.FontDialog fDialog = new Dart.PowerTCP.Emulation.FontDialog();

// Show the dialog.
if(fDialog.ShowDialog() == DialogResult.OK)
{
   // Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font;
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Font Class | Dart.PowerTCP.Emulation Namespace


Font Methods

The methods of the Font class are listed below. For a complete list of Font class members, see the Font Members topic.

Public Instance Methods

CompareTo | Compares this instance with a specified Object.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
ToHfont | Returns a handle to this Font object.
ToString | Returns a human-readable string representation of this Font object.

See Also

Font Class | Dart.PowerTCP.Emulation Namespace


Font.CompareTo Method

Compares this instance with a specified Object.

[Visual Basic]
NotOverridable Public Function CompareTo( _
ByVal obj As Object _
) As Integer Implements _
IComparable.CompareTo
[C#]
public int CompareTo(
object obj
);

Parameters

obj
An Object that evaluates to a Font

Return Value

A 32-bit signed integer indicating the lexical relationship between the two comparands.

Value | Condition
Less than zero | This instance is less than value.
Zero | This instance is equal to value.
Greater than zero | This instance is greater than value. -or- value is a null reference (Nothing in Visual Basic).

Implements

IComparable.CompareTo

See Also

Font Class | Dart.PowerTCP.Emulation Namespace


Font.ToHfont Method

Returns a handle to this Font object.

[Visual Basic]
Public Function ToHfont() As IntPtr
[C#]
public IntPtr ToHfont();

Return Value

A Windows handle to this Font object.

See Also

Font Class | Dart.PowerTCP.Emulation Namespace


Font.ToString Method

Returns a human-readable string representation of this Font object.

[Visual Basic]
Overrides Public Function ToString() As String
[C#]
public override string ToString();

Return Value

A string that represents this Font object.

See Also

Font Class | Dart.PowerTCP.Emulation Namespace


FontDialog Class

Represents a common dialog box that displays a list of fonts that are currently installed on the system.

For a list of all members of this type, see FontDialog Members.

System.Object
MarshalByRefObject
Component
CommonDialog
FontDialog

[Visual Basic]
Public Class FontDialog
Inherits CommonDialog
[C#]
public class FontDialog : CommonDialog

Remarks

This dialog is designed to work with the Font object included with PowerTCP Emulation for .NET, providing raster font capability to the .NET Framework.

Example

[Visual Basic, C#] The following example demonstrates dynamically creating a Font object.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Create a new Font object
Dim f as Dart.PowerTCP.Emulation.Font
f = New Dart.PowerTCP.Emulation.Font("courier", 7.5, FontStyle.Bold + FontStyle.Italic)
vt1.FontEx = f

' Display font info.
textBox1.Text = "Current font" & vbCrLf
textBox1.Text = textBox1.Text & "----------------" & vbCrLf
textBox1.Text = textBox1.Text & "Name: " & vt1.FontEx.Name & vbCrLf
textBox1.Text = textBox1.Text & "Size: " & vt1.FontEx.Size & vbCrLf
textBox1.Text = textBox1.Text & "Bold: " & vt1.FontEx.Bold & vbCrLf
textBox1.Text = textBox1.Text & "Italic: " & vt1.FontEx.Italic & vbCrLf
textBox1.Text = textBox1.Text & "Underline: " & vt1.FontEx.Underline & vbCrLf
textBox1.Text = textBox1.Text & "Strikeout: " & vt1.FontEx.Strikeout & vbCrLf
textBox1.Text = textBox1.Text & "Height: " & vt1.FontEx.Height & vbCrLf
textBox1.Text = textBox1.Text & "Type: " & vt1.FontEx.Type.ToString() & vbCrLF
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Font object
Dart.PowerTCP.Emulation.Font f;
f = new Dart.PowerTCP.Emulation.Font("courier", (float)7.5, FontStyle.Bold | FontStyle.Italic);
vt1.FontEx = f;

// Display font info.
textBox1.Text = "Current font\r\n";
textBox1.Text+= "----------------\r\n";
textBox1.Text+= "Name: " + vt1.FontEx.Name + "\r\n";
textBox1.Text+= "Size: " + vt1.FontEx.Size + "\r\n";
textBox1.Text+= "Bold: " + vt1.FontEx.Bold + "\r\n";
textBox1.Text+= "Italic: " + vt1.FontEx.Italic + "\r\n";
textBox1.Text+= "Underline: " + vt1.FontEx.Underline + "\r\n";
textBox1.Text+= "Strikeout: " + vt1.FontEx.Strikeout + "\r\n";
textBox1.Text+= "Height: " + vt1.FontEx.Height + "\r\n";
textBox1.Text+= "Type: " + vt1.FontEx.Type.ToString() + "\r\n";

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

[Visual Basic, C#] The following example demonstrates using the FontDialog class to set the FontEx propery.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.
' Create a new Dart.PowerTCP.Emulation.FontDialog class
Dim fDialog As New Dart.PowerTCP.Emulation.FontDialog()

' Show the dialog.
If fDialog.ShowDialog() = DialogResult.OK Then
   ' Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font
End If
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Dart.PowerTCP.Emulation.FontDialog class
Dart.PowerTCP.Emulation.FontDialog fDialog = new Dart.PowerTCP.Emulation.FontDialog();

// Show the dialog.
if(fDialog.ShowDialog() == DialogResult.OK)
{
   // Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font;
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: Dart.PowerTCP.Emulation

Assembly: DocEmulation (in DocEmulation.dll)

See Also

FontDialog Members | Dart.PowerTCP.Emulation Namespace


FontDialog Members

FontDialog overview

Public Instance Constructors

FontDialog Constructor Initializes a new instance of the FontDialog class.

Public Instance Properties

Container (inherited from Component) | Gets the IContainer that contains the Component.
Font | Gets or sets the selected font.
ShowApply | Gets or sets a value indicating whether the dialog box contains an Apply button.
Site (inherited from Component) | Gets or sets the ISite of the Component.

Public Instance Methods

CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from Component) | Releases all resources used by the Component.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Reset | Resets the properties of the dialog to their default values.
ShowDialog (inherited from CommonDialog) | Overloaded. Runs a common dialog box with a default owner.
ToString (inherited from Component) |

Public Instance Events

Apply | Raised when the Apply button is clicked.
Disposed (inherited from Component) | Adds an event handler to listen to the Disposed event on the component.
HelpRequest (inherited from CommonDialog) | Occurs when the user clicks the Help button on a common dialog box.

See Also

FontDialog Class | Dart.PowerTCP.Emulation Namespace


FontDialog Constructor

Initializes a new instance of the FontDialog class.

[Visual Basic]
Public Sub New()
[C#]
public FontDialog();

Remarks

The default constructor initializes any fields to their default values.

Example

[Visual Basic, C#] The following example demonstrates dynamically creating a Font object.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Create a new Font object
Dim f as Dart.PowerTCP.Emulation.Font
f = New Dart.PowerTCP.Emulation.Font("courier", 7.5, FontStyle.Bold + FontStyle.Italic)
vt1.FontEx = f

' Display font info.
textBox1.Text = "Current font" & vbCrLf
textBox1.Text = textBox1.Text & "----------------" & vbCrLf
textBox1.Text = textBox1.Text & "Name: " & vt1.FontEx.Name & vbCrLf
textBox1.Text = textBox1.Text & "Size: " & vt1.FontEx.Size & vbCrLf
textBox1.Text = textBox1.Text & "Bold: " & vt1.FontEx.Bold & vbCrLf
textBox1.Text = textBox1.Text & "Italic: " & vt1.FontEx.Italic & vbCrLf
textBox1.Text = textBox1.Text & "Underline: " & vt1.FontEx.Underline & vbCrLf
textBox1.Text = textBox1.Text & "Strikeout: " & vt1.FontEx.Strikeout & vbCrLf
textBox1.Text = textBox1.Text & "Height: " & vt1.FontEx.Height & vbCrLf
textBox1.Text = textBox1.Text & "Type: " & vt1.FontEx.Type.ToString() & vbCrLF
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Font object
Dart.PowerTCP.Emulation.Font f;
f = new Dart.PowerTCP.Emulation.Font("courier", (float)7.5, FontStyle.Bold | FontStyle.Italic);
vt1.FontEx = f;

// Display font info.
textBox1.Text = "Current font\r\n";
textBox1.Text+= "----------------\r\n";
textBox1.Text+= "Name: " + vt1.FontEx.Name + "\r\n";
textBox1.Text+= "Size: " + vt1.FontEx.Size + "\r\n";
textBox1.Text+= "Bold: " + vt1.FontEx.Bold + "\r\n";
textBox1.Text+= "Italic: " + vt1.FontEx.Italic + "\r\n";
textBox1.Text+= "Underline: " + vt1.FontEx.Underline + "\r\n";
textBox1.Text+= "Strikeout: " + vt1.FontEx.Strikeout + "\r\n";
textBox1.Text+= "Height: " + vt1.FontEx.Height + "\r\n";
textBox1.Text+= "Type: " + vt1.FontEx.Type.ToString() + "\r\n";

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

[Visual Basic, C#] The following example demonstrates using the FontDialog class to set the FontEx propery.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.
' Create a new Dart.PowerTCP.Emulation.FontDialog class
Dim fDialog As New Dart.PowerTCP.Emulation.FontDialog()

' Show the dialog.
If fDialog.ShowDialog() = DialogResult.OK Then
   ' Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font
End If
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Dart.PowerTCP.Emulation.FontDialog class
Dart.PowerTCP.Emulation.FontDialog fDialog = new Dart.PowerTCP.Emulation.FontDialog();

// Show the dialog.
if(fDialog.ShowDialog() == DialogResult.OK)
{
   // Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font;
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

FontDialog Class | Dart.PowerTCP.Emulation Namespace


FontDialog Properties

The properties of the FontDialog class are listed below. For a complete list of FontDialog class members, see the FontDialog Members topic.

Public Instance Properties

Container (inherited from Component) | Gets the IContainer that contains the Component.
Font | Gets or sets the selected font.
ShowApply | Gets or sets a value indicating whether the dialog box contains an Apply button.
Site (inherited from Component) | Gets or sets the ISite of the Component.

See Also

FontDialog Class | Dart.PowerTCP.Emulation Namespace


FontDialog.Font Property

Gets or sets the selected font.

[Visual Basic]
Public Property Font As Font
[C#]
public Font Font {get; set;}

Property Value

A Font object representing the selected font.

Example

[Visual Basic, C#] The following example demonstrates dynamically creating a Font object.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Create a new Font object
Dim f as Dart.PowerTCP.Emulation.Font
f = New Dart.PowerTCP.Emulation.Font("courier", 7.5, FontStyle.Bold + FontStyle.Italic)
vt1.FontEx = f

' Display font info.
textBox1.Text = "Current font" & vbCrLf
textBox1.Text = textBox1.Text & "----------------" & vbCrLf
textBox1.Text = textBox1.Text & "Name: " & vt1.FontEx.Name & vbCrLf
textBox1.Text = textBox1.Text & "Size: " & vt1.FontEx.Size & vbCrLf
textBox1.Text = textBox1.Text & "Bold: " & vt1.FontEx.Bold & vbCrLf
textBox1.Text = textBox1.Text & "Italic: " & vt1.FontEx.Italic & vbCrLf
textBox1.Text = textBox1.Text & "Underline: " & vt1.FontEx.Underline & vbCrLf
textBox1.Text = textBox1.Text & "Strikeout: " & vt1.FontEx.Strikeout & vbCrLf
textBox1.Text = textBox1.Text & "Height: " & vt1.FontEx.Height & vbCrLf
textBox1.Text = textBox1.Text & "Type: " & vt1.FontEx.Type.ToString() & vbCrLF
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Font object
Dart.PowerTCP.Emulation.Font f;
f = new Dart.PowerTCP.Emulation.Font("courier", (float)7.5, FontStyle.Bold | FontStyle.Italic);
vt1.FontEx = f;

// Display font info.
textBox1.Text = "Current font\r\n";
textBox1.Text+= "----------------\r\n";
textBox1.Text+= "Name: " + vt1.FontEx.Name + "\r\n";
textBox1.Text+= "Size: " + vt1.FontEx.Size + "\r\n";
textBox1.Text+= "Bold: " + vt1.FontEx.Bold + "\r\n";
textBox1.Text+= "Italic: " + vt1.FontEx.Italic + "\r\n";
textBox1.Text+= "Underline: " + vt1.FontEx.Underline + "\r\n";
textBox1.Text+= "Strikeout: " + vt1.FontEx.Strikeout + "\r\n";
textBox1.Text+= "Height: " + vt1.FontEx.Height + "\r\n";
textBox1.Text+= "Type: " + vt1.FontEx.Type.ToString() + "\r\n";

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

[Visual Basic, C#] The following example demonstrates using the FontDialog class to set the FontEx propery.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.
' Create a new Dart.PowerTCP.Emulation.FontDialog class
Dim fDialog As New Dart.PowerTCP.Emulation.FontDialog()

' Show the dialog.
If fDialog.ShowDialog() = DialogResult.OK Then
   ' Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font
End If
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Dart.PowerTCP.Emulation.FontDialog class
Dart.PowerTCP.Emulation.FontDialog fDialog = new Dart.PowerTCP.Emulation.FontDialog();

// Show the dialog.
if(fDialog.ShowDialog() == DialogResult.OK)
{
   // Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font;
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

FontDialog Class | Dart.PowerTCP.Emulation Namespace


FontDialog.ShowApply Property

Gets or sets a value indicating whether the dialog box contains an Apply button.

[Visual Basic]
Public ReadOnly Property ShowApply As Boolean
[C#]
public bool ShowApply {get;}

Property Value

true if the dialog box contains an Apply button; otherwise, false. The default value is false.

See Also

FontDialog Class | Dart.PowerTCP.Emulation Namespace


FontDialog Methods

The methods of the FontDialog class are listed below. For a complete list of FontDialog class members, see the FontDialog Members topic.

Public Instance Methods

CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from Component) | Releases all resources used by the Component.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Reset | Resets the properties of the dialog to their default values.
ShowDialog (inherited from CommonDialog) | Overloaded. Runs a common dialog box with a default owner.
ToString (inherited from Component) |

See Also

FontDialog Class | Dart.PowerTCP.Emulation Namespace


FontDialog.Reset Method

Resets the properties of the dialog to their default values.

[Visual Basic]
Overrides Public Sub Reset()
[C#]
public override void Reset();

See Also

FontDialog Class | Dart.PowerTCP.Emulation Namespace


FontDialog Events

The events of the FontDialog class are listed below. For a complete list of FontDialog class members, see the FontDialog Members topic.

Public Instance Events

Apply | Raised when the Apply button is clicked.
Disposed (inherited from Component) | Adds an event handler to listen to the Disposed event on the component.
HelpRequest (inherited from CommonDialog) | Occurs when the user clicks the Help button on a common dialog box.

See Also

FontDialog Class | Dart.PowerTCP.Emulation Namespace


FontDialog.Apply Event

Raised when the Apply button is clicked.

[Visual Basic]
Public Event Apply As EventHandler
[C#]
public event EventHandler Apply;

See Also

FontDialog Class | Dart.PowerTCP.Emulation Namespace


FontEditor Class

Provides a user interface to select and configure a Font object.

For a list of all members of this type, see FontEditor Members.

System.Object
UITypeEditor
FontEditor

[Visual Basic]
Public Class FontEditor
Inherits UITypeEditor
[C#]
public class FontEditor : UITypeEditor

Remarks

This editor is designed to work with the Font object included with PowerTCP Emulation for .NET, providing raster font capability to the .NET Framework.

Requirements

Namespace: Dart.PowerTCP.Emulation

Assembly: DocEmulation (in DocEmulation.dll)

See Also

FontEditor Members | Dart.PowerTCP.Emulation Namespace


FontEditor Members

FontEditor overview

Public Instance Constructors

FontEditor Constructor Initializes a new instance of the FontEditor class.

Public Instance Methods

EditValue (inherited from UITypeEditor) | Overloaded. Edits the specified object's value using the editor style indicated by GetEditStyle.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetEditStyle (inherited from UITypeEditor) | Overloaded. Gets the editor style used by the EditValue method.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetPaintValueSupported (inherited from UITypeEditor) | Overloaded. Indicates whether the specified context supports painting a representation of an object's value within the specified context.
GetType (inherited from Object) | Gets the Type of the current instance.
PaintValue (inherited from UITypeEditor) | Overloaded. Paints a representation of the value of an object using the specified PaintValueEventArgs.
ToString (inherited from Object) | Returns a String that represents the current Object.

See Also

FontEditor Class | Dart.PowerTCP.Emulation Namespace


FontEditor Constructor

Initializes a new instance of the FontEditor class.

[Visual Basic]
Public Sub New()
[C#]
public FontEditor();

Remarks

The default constructor initializes any fields to their default values.

See Also

FontEditor Class | Dart.PowerTCP.Emulation Namespace


FontType Enumeration

Specifies font types.

[Visual Basic]
Public Enum FontType
[C#]
public enum FontType

Remarks

Microsoft .NET Framework only supports TrueType and OpenType fonts while PowerTCP supports these types and Raster fonts.

Example

[Visual Basic, C#] The following example demonstrates dynamically creating a Font object.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Create a new Font object
Dim f as Dart.PowerTCP.Emulation.Font
f = New Dart.PowerTCP.Emulation.Font("courier", 7.5, FontStyle.Bold + FontStyle.Italic)
vt1.FontEx = f

' Display font info.
textBox1.Text = "Current font" & vbCrLf
textBox1.Text = textBox1.Text & "----------------" & vbCrLf
textBox1.Text = textBox1.Text & "Name: " & vt1.FontEx.Name & vbCrLf
textBox1.Text = textBox1.Text & "Size: " & vt1.FontEx.Size & vbCrLf
textBox1.Text = textBox1.Text & "Bold: " & vt1.FontEx.Bold & vbCrLf
textBox1.Text = textBox1.Text & "Italic: " & vt1.FontEx.Italic & vbCrLf
textBox1.Text = textBox1.Text & "Underline: " & vt1.FontEx.Underline & vbCrLf
textBox1.Text = textBox1.Text & "Strikeout: " & vt1.FontEx.Strikeout & vbCrLf
textBox1.Text = textBox1.Text & "Height: " & vt1.FontEx.Height & vbCrLf
textBox1.Text = textBox1.Text & "Type: " & vt1.FontEx.Type.ToString() & vbCrLF
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Font object
Dart.PowerTCP.Emulation.Font f;
f = new Dart.PowerTCP.Emulation.Font("courier", (float)7.5, FontStyle.Bold | FontStyle.Italic);
vt1.FontEx = f;

// Display font info.
textBox1.Text = "Current font\r\n";
textBox1.Text+= "----------------\r\n";
textBox1.Text+= "Name: " + vt1.FontEx.Name + "\r\n";
textBox1.Text+= "Size: " + vt1.FontEx.Size + "\r\n";
textBox1.Text+= "Bold: " + vt1.FontEx.Bold + "\r\n";
textBox1.Text+= "Italic: " + vt1.FontEx.Italic + "\r\n";
textBox1.Text+= "Underline: " + vt1.FontEx.Underline + "\r\n";
textBox1.Text+= "Strikeout: " + vt1.FontEx.Strikeout + "\r\n";
textBox1.Text+= "Height: " + vt1.FontEx.Height + "\r\n";
textBox1.Text+= "Type: " + vt1.FontEx.Type.ToString() + "\r\n";

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

[Visual Basic, C#] The following example demonstrates using the FontDialog class to set the FontEx propery.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.
' Create a new Dart.PowerTCP.Emulation.FontDialog class
Dim fDialog As New Dart.PowerTCP.Emulation.FontDialog()

' Show the dialog.
If fDialog.ShowDialog() = DialogResult.OK Then
   ' Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font
End If
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Dart.PowerTCP.Emulation.FontDialog class
Dart.PowerTCP.Emulation.FontDialog fDialog = new Dart.PowerTCP.Emulation.FontDialog();

// Show the dialog.
if(fDialog.ShowDialog() == DialogResult.OK)
{
   // Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font;
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Members

Member Name | Description
Raster | Font is a bitmap.
Type1 | Standard font for publishing. Created by Adobe.
TrueType | Font is defined by line and curve commands.
OpenType | New, cross platform font standard. Jointly created by Adobe and Microsoft.

Requirements

Namespace: Dart.PowerTCP.Emulation

Assembly: DocEmulation (in DocEmulation.dll)

See Also

Dart.PowerTCP.Emulation Namespace


Keypad Enumeration

Enumerates the values of the Vt.Keypad property. The keypad can generate numeric values or application-specific values.

[Visual Basic]
Public Enum Keypad
[C#]
public enum Keypad

Example

[Visual Basic, C#] The following example demonstrates setting many of the simple properties to non-default values.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = False

' Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = False

' Set so lines do not wrap if they are too long.
vt1.AutoWrap = True

' Set backcolor to Red
vt1.BackColor = Color.Red

' Disable bell
vt1.Bell = False

' Set Blink Intensity to 40
vt1.BlinkIntensity = 40

' Set bold text color to Blue
vt1.BoldColor = Color.Blue

' Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application

' Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = New System.Drawing.Point(5, 5)

' Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline

' Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow

' "Swap" the foreground and background colors.
vt1.Inverse = True

' Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application

' Echo any typed keys to the display.
vt1.LocalEcho = True

' Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British

' Set Normal Intensity to 80
vt1.NormalIntensity = 80

' Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = New System.Drawing.Size(70, 20)

' Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump

' Change the size of the control to 250 X 100
vt1.Size = New System.Drawing.Size(250, 100)

' Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30"

' Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = False
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = false;

// Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = false;

// Set so lines do not wrap if they are too long.
vt1.AutoWrap = true;

// Set backcolor to Red
vt1.BackColor = Color.Red;

// Disable bell
vt1.Bell = false;

// Set Blink Intensity to 40
vt1.BlinkIntensity = 40;

// Set bold text color to Blue
vt1.BoldColor = Color.Blue;

// Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application;

// Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = new System.Drawing.Point(5, 5);

// Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline;

// Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow;

// "Swap" the foreground and background colors.
vt1.Inverse = true;

// Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application;

// Echo any typed keys to the display.
vt1.LocalEcho = true;

// Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British;

// Set Normal Intensity to 80
vt1.NormalIntensity = 80;

// Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = new System.Drawing.Size(70, 20);

// Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump;

// Change the size of the control to 250 X 100
vt1.Size = new System.Drawing.Size(250, 100);

// Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30";

// Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = false;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Members

Member Name | Description
Numeric | Keypad keys generate numeric values.
Application | Keypad keys generate application specific values.

Requirements

Namespace: Dart.PowerTCP.Emulation

Assembly: DocEmulation (in DocEmulation.dll)

See Also

Dart.PowerTCP.Emulation Namespace


NationalCharSet Enumeration

Enumerates the national character sets exposed by the Vt.NationalCharSet property.

[Visual Basic]
Public Enum NationalCharSet
[C#]
public enum NationalCharSet

Example

[Visual Basic, C#] The following example demonstrates setting many of the simple properties to non-default values.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = False

' Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = False

' Set so lines do not wrap if they are too long.
vt1.AutoWrap = True

' Set backcolor to Red
vt1.BackColor = Color.Red

' Disable bell
vt1.Bell = False

' Set Blink Intensity to 40
vt1.BlinkIntensity = 40

' Set bold text color to Blue
vt1.BoldColor = Color.Blue

' Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application

' Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = New System.Drawing.Point(5, 5)

' Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline

' Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow

' "Swap" the foreground and background colors.
vt1.Inverse = True

' Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application

' Echo any typed keys to the display.
vt1.LocalEcho = True

' Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British

' Set Normal Intensity to 80
vt1.NormalIntensity = 80

' Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = New System.Drawing.Size(70, 20)

' Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump

' Change the size of the control to 250 X 100
vt1.Size = New System.Drawing.Size(250, 100)

' Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30"

' Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = False
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = false;

// Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = false;

// Set so lines do not wrap if they are too long.
vt1.AutoWrap = true;

// Set backcolor to Red
vt1.BackColor = Color.Red;

// Disable bell
vt1.Bell = false;

// Set Blink Intensity to 40
vt1.BlinkIntensity = 40;

// Set bold text color to Blue
vt1.BoldColor = Color.Blue;

// Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application;

// Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = new System.Drawing.Point(5, 5);

// Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline;

// Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow;

// "Swap" the foreground and background colors.
vt1.Inverse = true;

// Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application;

// Echo any typed keys to the display.
vt1.LocalEcho = true;

// Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British;

// Set Normal Intensity to 80
vt1.NormalIntensity = 80;

// Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = new System.Drawing.Size(70, 20);

// Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump;

// Change the size of the control to 250 X 100
vt1.Size = new System.Drawing.Size(250, 100);

// Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30";

// Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = false;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Members

Member Name | Description
Ascii | ASCII mode (no national character set replacement).
British | British character set.
Dutch | Dutch character set.
Finnish | Finnish character set.
French | French character set.
FrenchCanadian | French Canadian character set.
German | German character set.
Italian | Italian character set.
NorwegianDanish | Norwegian Danish character set.
Portuguese | Portuguese character set.
Spanish | Spanish character set.
Swedish | Swedish character set.
Swiss | Swiss character set.

Requirements

Namespace: Dart.PowerTCP.Emulation

Assembly: DocEmulation (in DocEmulation.dll)

See Also

Dart.PowerTCP.Emulation Namespace


NewLine Enumeration

Enumerates the end-of-line sequences sent to the host in response to an end of line character (ENTER key). Used by the Vt.NewLine property.

[Visual Basic]
Public Enum NewLine
[C#]
public enum NewLine

Example

[Visual Basic, C#] The following example demonstrates simple use of the AutoPrint feature.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.
' Clear the Vt display
vt1.Clear()

' Change line terminator
vt1.NewLine = NewLine.CrLf

' Turn on auto print
vt1.Print = PrintType.Auto

' Simulate data ariving from host. Data should print
' with each CRLF received.
vt1.Write("line 1" & vbCrLF)
vt1.Write("line 2" & vbCrLf)
vt1.Write("line 3" & vbCrLf)

' Terminate print job
vt1.Print = PrintType.Off
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Clear the Vt display
vt1.Clear();

// Change line terminator
vt1.NewLine = NewLine.CrLf;

// Turn on auto print
vt1.Print = PrintType.Auto;

// Simulate data ariving from host. Data should print
// with each CRLF received.
vt1.Write("line 1\r\n");
vt1.Write("line 2\r\n");
vt1.Write("line 3\r\n");

// Terminate print job
vt1.Print = PrintType.Off;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

[Visual Basic, C#] The following example demonstrates

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Members

Member Name | Description
Cr | CR only (ASCII 13).
CrLf | CR/LF combination (ASCII 13 and ASCII 10).

Requirements

Namespace: Dart.PowerTCP.Emulation

Assembly: DocEmulation (in DocEmulation.dll)

See Also

Dart.PowerTCP.Emulation Namespace


PrintType Enumeration

Enumerates the printing types used by the Vt control.

[Visual Basic]
Public Enum PrintType
[C#]
public enum PrintType

Example

[Visual Basic, C#] The following example demonstrates simple use of the AutoPrint feature.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.
' Clear the Vt display
vt1.Clear()

' Change line terminator
vt1.NewLine = NewLine.CrLf

' Turn on auto print
vt1.Print = PrintType.Auto

' Simulate data ariving from host. Data should print
' with each CRLF received.
vt1.Write("line 1" & vbCrLF)
vt1.Write("line 2" & vbCrLf)
vt1.Write("line 3" & vbCrLf)

' Terminate print job
vt1.Print = PrintType.Off
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Clear the Vt display
vt1.Clear();

// Change line terminator
vt1.NewLine = NewLine.CrLf;

// Turn on auto print
vt1.Print = PrintType.Auto;

// Simulate data ariving from host. Data should print
// with each CRLF received.
vt1.Write("line 1\r\n");
vt1.Write("line 2\r\n");
vt1.Write("line 3\r\n");

// Terminate print job
vt1.Print = PrintType.Off;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

[Visual Basic, C#] The following example demonstrates

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Members

Member Name | Description
Off | No automatic printing. Printing must be done explicitly by calling Vt.PrintScreen(), Vt.PrintSelectedText(), or Vt.PrintCursorLine.
Auto | Printing occurs line by line as data termimated with a line terminator is received from the host. Received data is displayed on the Vt display.
Controller | Printing occurs line by line as data terminated with a line terminator is received from the host. Received data is not displayed on the Vt display.

Requirements

Namespace: Dart.PowerTCP.Emulation

Assembly: DocEmulation (in DocEmulation.dll)

See Also

Dart.PowerTCP.Emulation Namespace


Scroll Enumeration

Enumerates the values of the Vt.ScrollType property. The display screen can perform smooth scrolling or jump scrolling.

[Visual Basic]
Public Enum Scroll
[C#]
public enum Scroll

Example

[Visual Basic, C#] The following example demonstrates setting many of the simple properties to non-default values.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = False

' Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = False

' Set so lines do not wrap if they are too long.
vt1.AutoWrap = True

' Set backcolor to Red
vt1.BackColor = Color.Red

' Disable bell
vt1.Bell = False

' Set Blink Intensity to 40
vt1.BlinkIntensity = 40

' Set bold text color to Blue
vt1.BoldColor = Color.Blue

' Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application

' Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = New System.Drawing.Point(5, 5)

' Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline

' Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow

' "Swap" the foreground and background colors.
vt1.Inverse = True

' Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application

' Echo any typed keys to the display.
vt1.LocalEcho = True

' Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British

' Set Normal Intensity to 80
vt1.NormalIntensity = 80

' Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = New System.Drawing.Size(70, 20)

' Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump

' Change the size of the control to 250 X 100
vt1.Size = New System.Drawing.Size(250, 100)

' Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30"

' Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = False
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = false;

// Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = false;

// Set so lines do not wrap if they are too long.
vt1.AutoWrap = true;

// Set backcolor to Red
vt1.BackColor = Color.Red;

// Disable bell
vt1.Bell = false;

// Set Blink Intensity to 40
vt1.BlinkIntensity = 40;

// Set bold text color to Blue
vt1.BoldColor = Color.Blue;

// Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application;

// Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = new System.Drawing.Point(5, 5);

// Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline;

// Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow;

// "Swap" the foreground and background colors.
vt1.Inverse = true;

// Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application;

// Echo any typed keys to the display.
vt1.LocalEcho = true;

// Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British;

// Set Normal Intensity to 80
vt1.NormalIntensity = 80;

// Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = new System.Drawing.Size(70, 20);

// Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump;

// Change the size of the control to 250 X 100
vt1.Size = new System.Drawing.Size(250, 100);

// Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30";

// Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = false;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Members

Member Name | Description
Jump | Scrolling uses jump scrolling (scrolls line by line).
Smooth | Scrolling uses smooth scrolling.

Requirements

Namespace: Dart.PowerTCP.Emulation

Assembly: DocEmulation (in DocEmulation.dll)

See Also

Dart.PowerTCP.Emulation Namespace


Style Enumeration

Enumerates the character styles for text. One or more of these values are added together to represent the style of each character.

[Visual Basic]
Public Enum Style
[C#]
public enum Style

Members

Member Name | Description
Normal | 0 Normal character style.
Inverse | 1 Foreground and background colors are reverse.
Bold | 2 Character color is bolded.
Blink | 4 Character is set to blink.
Underline | 8 Character is underlined.

Requirements

Namespace: Dart.PowerTCP.Emulation

Assembly: DocEmulation (in DocEmulation.dll)

See Also

Dart.PowerTCP.Emulation Namespace


Styles Enumeration

Enumerates the styles for a cell. Used by the Cell.Styles property.

[Visual Basic]
Public Enum Styles
[C#]
public enum Styles

Example

[Visual Basic, C#] The following example demonstrates using the ScrapeCells method to discover info about a cell.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

Private Sub ShowCellInfo(ByVal row As Integer, ByVal col As Integer)
   ' Scrape the row and column specified.
   Dim cells as Cell() = vt1.ScrapeCells(row, col, 1)

   ' Display info about the cell.
   textBox1.Text = "Character: " & cells(0).Character
   textBox1.Text = textBox1.Text & " (" & CChar(cells(0).Character) & ")" & vbCrLf
   textBox1.Text = textBox1.Text & "Raw Character: " & cells(0).RawCharacter
   textBox1.Text = textBox1.Text & " (" & CChar(cells(0).RawCharacter) & ")" & vbCrLf
   textBox1.Text = textBox1.Text & "Background color: " & cells(0).BackColor & vbCrLf
   textBox1.Text = textBox1.Text & "Foreground color: " & cells(0).ForeColor & vbCrLf
   textBox1.Text = textBox1.Text & "Styles: " & cells(0).Styles
End Sub

' Use the following code to test the function

' Disable buffer
vt1.BufferRows = 0

' Clear the display
vt1.Clear()

' Add some dummy data
vt1.Write(Chr(27) + "[1mTest " + Chr(27) + "[0mdata" + Chr(27) + "[7m blah " + Chr(27) + "[0m")

' Call the function
ShowCellInfo(0, 3)
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

private void ShowCellInfo(int row, int col)
{
   // Scrape the row and column specified.
   Cell[] cells = vt1.ScrapeCells(row, col, 1);

   // Display info about the cell.
   textBox1.Text = "Character: " + cells[0].Character;
   textBox1.Text+= " (" + (char)cells[0].Character + ")" + "\r\n";
   textBox1.Text+= "Raw Character: " + cells[0].RawCharacter;
   textBox1.Text+= " (" + (char)cells[0].RawCharacter + ")" + "\r\n";
   textBox1.Text+= "Background color: " + cells[0].BackColor + "\r\n";
   textBox1.Text+= "Foreground color: " + cells[0].ForeColor + "\r\n";
   textBox1.Text+= "Styles: " + cells[0].Styles;
}

// Use the following code to test the function

// Disable buffer
vt1.BufferRows = 0;

// Clear the display
vt1.Clear();

// Add some dummy data
vt1.Write("\x1b[1mTest \x1b[0mdata\x1b[7m blah \x1b[0m");

// Call the function
ShowCellInfo(0, 3);

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Members

Member Name | Description
Normal | 0 No style applied, normal character style.
Inverse | 1 Foreground and background colors are reversed.
Bold | 2 Character color is bolded.
Blink | 4 Character is set to blink.
Underline | 8 Character is underlined.
DoubleWide | 16 Character is twice as wide as normal and occupies 2 cells.
DoubleHighTop | 32 Top half of double-height character is displayed.
DoubleHighBottom | 64 Bottom half of double-height character is displayed.
SpecialGrapic | 128 Character is a special graphic.

Requirements

Namespace: Dart.PowerTCP.Emulation

Assembly: DocEmulation (in DocEmulation.dll)

See Also

Dart.PowerTCP.Emulation Namespace


Telnet Class

For information on the Telnet class, please see the Telnet for .NET documentation.

For a list of all members of this type, see Telnet Members.

System.Object
MarshalByRefObject
Component
Telnet

[Visual Basic]
Public Class Telnet
Inherits Component
[C#]
public class Telnet : Component

Requirements

Namespace: Dart.PowerTCP.Emulation

Assembly: DocEmulation (in DocEmulation.dll)

See Also

Telnet Members | Dart.PowerTCP.Emulation Namespace


Telnet Members

Telnet overview

Public Instance Constructors

Telnet Constructor Initializes a new instance of the Telnet class.

Public Instance Properties

Container (inherited from Component) | Gets the IContainer that contains the Component.
Site (inherited from Component) | Gets or sets the ISite of the Component.

Public Instance Methods

CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from Component) | Releases all resources used by the Component.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
ToString (inherited from Component) |

Public Instance Events

Disposed (inherited from Component) Adds an event handler to listen to the Disposed event on the component.

See Also

Telnet Class | Dart.PowerTCP.Emulation Namespace


Telnet Constructor

Initializes a new instance of the Telnet class.

[Visual Basic]
Public Sub New()
[C#]
public Telnet();

See Also

Telnet Class | Dart.PowerTCP.Emulation Namespace


TerminalType Enumeration

Enumerates the values of the Vt.TerminalType property.

[Visual Basic]
Public Enum TerminalType
[C#]
public enum TerminalType

Members

Member Name | Description
Tty | 1 No emulation.
Vt52 | 2 VT52 terminal emulation.
Vt100 | 3 VT100 terminal emulation.
Vt220_7 | 4 VT220 terminal emulation, 7-bit only.
Vt220_8 | 5 VT220 terminal emulation, 8-bit.
Vt320_7 | 45 VT320 terminal emulation, 7-bit only.
Vt320_8 | 46 VT320 terminal emulation, 8-bit.

Requirements

Namespace: Dart.PowerTCP.Emulation

Assembly: DocEmulation (in DocEmulation.dll)

See Also

Dart.PowerTCP.Emulation Namespace


Vt Class

Represents a terminal emulator used to display VT formatted data.

For a list of all members of this type, see Vt Members.

System.Object
MarshalByRefObject
Component
Control
Vt

[Visual Basic]
Public Class Vt
Inherits Control
[C#]
public class Vt : Control

Remarks

Use the Vt component to process data received from a host application and targeted for a VT terminal. By streaming this data into a Vt component, you can either:

  • Display it to the user (like most emulation products).
  • Screen scrape it and format the text into a custom report of your own design.

If you do not first process the data with a Vt component, you are left with a stream of data containing numerous escape codes. The Vt component provides terminal emulation as defined by Digital Equipment Corporation for their VT data terminals. It differs from other controls like TCP and Telnet since it is used for data display and formatting, not communications. VT52, VT100, VT220, and VT320 emulation is supported. Each emulation contains formatting rules (escape codes) for interpreting incoming data. For example, one sequence may dictate that the display screen be filled with spaces, while another directs that the cursor be moved to a specified location. DEC developed the VT escape codes for their VT terminals, which contained a screen, keyboard, printer port, and an RS-232 connection for connecting to the host. By performing this same functionality in software using high-speed LAN connectivity, the Vt component provides a faster display screen, flexible keyboard mapping, and printing to the Windows default printer—a big improvement over previous hardware devices.

Example

[Visual Basic, C#] The following example demonstrates creating a simple VT application using the internal Telnet control. In addition, creating a diagnostic log using the Capture method is also demonstrated.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.
Dim f as System.IO.FileStream

Private Sub OpenTelnetConnection()
   ' Create a new filestream
   f = New System.IO.FileStream("C:\temp\log.txt", System.IO.FileMode.Create)

   ' Capture all data displayed on the Vt window
   vt1.Capture(f)

   ' Connect to a Telnet server
   vt1.Telnet.Connect("myserver")
End Sub

Private Void CloseTelnetConnection()
   ' Close the connection
   vt1.Telnet.Close()

   ' Close the filestream
   f.Close()
End Sub
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

System.IO.FileStream  f = null;

private void OpenTelnetConnection()
{
   // Create a new filestream
   f = new System.IO.FileStream("C:\\temp\\log.txt", System.IO.FileMode.Create);

   // Capture all data displayed on the Vt window
   vt1.Capture(f);

   // Connect to a Telnet server
   vt1.Telnet.Connect("myserver");
}

private void CloseTelnetConnection()
{
   // Close the connection
   vt1.Telnet.Close();

   // Close the filestream
   f.Close();
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: Dart.PowerTCP.Emulation

Assembly: DocEmulation (in DocEmulation.dll)

See Also

Vt Members | Dart.PowerTCP.Emulation Namespace


Vt Members

Vt overview

Public Instance Constructors

Vt Overloaded. Initializes a new instance of the Vt class.

Public Instance Properties

AcceptTabs | Gets or sets whether to retain focus when the tab key is used.
AccessibilityObject (inherited from Control) | Gets the AccessibleObject assigned to the control.
AccessibleDefaultActionDescription (inherited from Control) | Gets or sets the default action description of the control for use by accessibility client applications.
AccessibleDescription (inherited from Control) | Gets or sets the description of the control used by accessibility client applications.
AccessibleName (inherited from Control) | Gets or sets the name of the control used by accessibility client applications.
AccessibleRole (inherited from Control) | Gets or sets the accessible role of the control
AllowDrop (inherited from Control) | Gets or sets a value indicating whether the control can accept data that the user drags onto it.
Anchor (inherited from Control) | Gets or sets which edges of the control are anchored to the edges of its container.
Answer | Gets or sets a string expression to be sent by the control whenever an ENQ is received.
AutoRepeat | Gets or sets a value that determines whether depressed keys generate more than one character.
AutoWrap | Gets or sets a value that indicates whether display text stops at the last column or wraps to the next line when a line contains more data than can fit on one row.
BackColor | Gets or sets the background color for the control.
BackgroundImage (inherited from Control) | Gets or sets the background image displayed in the control.
Bell | Gets or sets a value that determines whether an audio bell is enabled.
BindingContext (inherited from Control) | Gets or sets the BindingContext for the control.
BlinkIntensity | Gets or sets the "brightness" of blinking text.
BoldColor | Gets or sets the color of bold text.
Bottom (inherited from Control) | Gets the distance between the bottom edge of the control and the top edge of its container's client area.
Bounds (inherited from Control) | Gets or sets the size and location of the control including its nonclient elements.
BufferRows | Gets or sets the number of rows stored in the scrollback buffer.
CanFocus (inherited from Control) | Gets a value indicating whether the control can receive focus.
CanSelect (inherited from Control) | Gets a value indicating whether the control can be selected.
CausesValidation (inherited from Control) | Gets or sets a value indicating whether the control causes validation to be performed on any controls that require validation when it receives focus.
ClientRectangle (inherited from Control) | Gets the rectangle that represents the client area of the control.
ClientSize (inherited from Control) | Gets or sets the height and width of the client area of the control.
CompanyName (inherited from Control) | Gets the name of the company or creator of the application containing the control.
Container (inherited from Component) | Gets the IContainer that contains the Component.
ContainsFocus (inherited from Control) | Gets a value indicating whether the control, or one of its child controls, currently has the input focus.
ContextMenu (inherited from Control) | Gets or sets the shortcut menu associated with the control.
Controls (inherited from Control) | Gets the collection of controls contained within the control.
Created (inherited from Control) | Gets a value indicating whether the control has been created.
Cursor (inherited from Control) | Gets or sets the cursor that is displayed when the mouse pointer is over the control.
CursorKeys | Gets or sets a value that determines whether the cursor keys send ANSI cursor control sequences (up, down, left, right) or application control sequences.
CursorStyle | Gets or sets a value which indicates the cursor style.
DataBindings (inherited from Control) | Gets the data bindings for the control.
DisplayRectangle (inherited from Control) | Gets the rectangle that represents the display area of the control.
Disposing (inherited from Control) | Gets a value indicating whether the control is in the process of being disposed of.
Dock (inherited from Control) | Gets or sets which edge of the parent container a control is docked to.
Enabled (inherited from Control) | Gets or sets a value indicating whether the control can respond to user interaction.
Focused (inherited from Control) | Gets a value indicating whether the control has input focus.
Font | NEVER USE THE VT.FONT PROPERTY. USE VT.FONTEX INSTEAD.
FontEx | Gets or sets the font used in the display of the control.
ForeColor | Gets or sets the foreground color for the control.
Handle (inherited from Control) | Gets the window handle that the control is bound to.
HasChildren (inherited from Control) | Gets a value indicating whether the control contains one or more child controls.
Height (inherited from Control) | Gets or sets the height of the control.
ImeMode (inherited from Control) | Gets or sets the Input Method Editor (IME) mode of the control.
Inverse | Gets or sets a value that determines whether the foreground and background colors are switched.
InvokeRequired (inherited from Control) | Gets a value indicating whether the caller must call an invoke method when making method calls to the control because the caller is on a different thread than the one the control was created on.
IsAccessible (inherited from Control) | Gets or sets a value indicating whether the control is visible to accessibility applications.
IsDisposed (inherited from Control) | Gets a value indicating whether the control has been disposed of.
IsHandleCreated (inherited from Control) | Gets a value indicating whether the control has a handle associated with it.
KeyPad | Gets or sets a value that determines whether the keypad sends ASCII characters or escape sequences.
Left (inherited from Control) | Gets or sets the x-coordinate of a control's left edge in pixels.
LocalEcho | Gets or sets a value which controls whether or not key presses are displayed on the Vt window.
Location (inherited from Control) | Gets or sets the coordinates of the upper-left corner of the control relative to the upper-left corner of its container.
Margin | Gets or sets a Size object which determines the amount of "buffer" space around the Vt content on the window.
Name (inherited from Control) | Gets or sets the name of the control.
NationalCharSet | Gets or sets the national character set for use in VT220 7-bit or VT320 7-bit emulation modes to display special characters that normally require 8-bit emulation mode.
NewLine | Gets or sets the end-of-line character sequence to use.
NormalIntensity | Gets or sets the "brightness" of normal text.
Parent (inherited from Control) | Gets or sets the parent container of the control.
Print | Gets or sets a PrintType specifying how printing should occur.
PrintPassthrough | Gets or sets a value that determines if printing bypasses the normal printer drivers and prints directly to the printer port.
ProductName (inherited from Control) | Gets the product name of the assembly containing the control.
ProductVersion (inherited from Control) | Gets the version of the assembly containing the control.
RecreatingHandle (inherited from Control) | Gets a value indicating whether the control is currently re-creating its handle.
Region (inherited from Control) | Gets or sets the window region associated with the control.
Right (inherited from Control) | Gets the distance between the right edge of the control and the left edge of its container.
RightToLeft (inherited from Control) | Gets or sets a value indicating whether control's elements are aligned to support locales using right-to-left fonts.
ScreenSize | Gets or sets the screen size (number of columns and rows) used by the Vt window.
ScrollType | Gets or sets a value that determines whether to use jump scrolling or smooth scrolling in the display screen.
SelectedText | Gets the currently selected text.
SelectionLength | Gets or sets the length of the number of characters selected.
SelectionStart | Gets or sets the starting index of the characters currently selected.
Site (inherited from Control) | Gets or sets the site of the control.
Size (inherited from Control) | Gets or sets the height and width of the control.
StatusLine | Gets or sets a value that indicates whether a 25th line is displayed as a status line when in VT320 7-bit or 8-bit mode.
TabIndex (inherited from Control) | Gets or sets the tab order of the control within its container.
Tabs | Gets or sets a list of comma-delimited tab positions.
TabStop (inherited from Control) | Gets or sets a value indicating whether the user can give the focus to this control using the TAB key.
Tag (inherited from Control) | Gets or sets the object that contains data about the control.
Telnet | Gets the internal Telnet control to use for online communications.
TerminalType | Gets or sets the terminal type to emulate.
Text | DO NOT USE THE TEXT PROPERTY. USE THE WRITE METHOD TO ADD TEXT TO THE VT AND THE SCRAPETEXT METHOD TO GET TEXT FROM THE VT.
TextLength | Returns the length of the data in the Vt window.
Top (inherited from Control) | Gets or sets the y-coordinate of the control's top edge in pixels.
TopLevelControl (inherited from Control) | Gets the parent control that is not parented by another Windows Forms control. Typically, this is the outermost Form that the control is contained in.
UseDefaultPrinter | Gets or sets a value which indicates whether the system default printer or a user-selected printer is used.
Visible (inherited from Control) | Gets or sets a value indicating whether the control is displayed.
Width (inherited from Control) | Gets or sets the width of the control.
WindowTarget (inherited from Control) |

Public Instance Methods

BeginInvoke (inherited from Control) | Overloaded. Executes the specified delegate asynchronously with the specified arguments, on the thread that the control's underlying handle was created on.
BringToFront (inherited from Control) | Brings the control to the front of the z-order.
Capture | Save subsequent display data to the provided stream.
Clear | Clears the scrollback buffer and all rows in the display screen.
Contains (inherited from Control) | Retrieves a value indicating whether the specified control is a child of the control.
CreateControl (inherited from Control) | Forces the creation of the control, including the creation of the handle and any child controls.
CreateGraphics (inherited from Control) | Creates the Graphics object for the control.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from Component) | Releases all resources used by the Component.
DoDragDrop (inherited from Control) | Begins a drag-and-drop operation.
EndInvoke (inherited from Control) | Retrieves the return value of the asynchronous operation represented by the IAsyncResult object passed.
EnsureVisible | Scrolls the screen to ensure the specified row is visible.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
FindForm (inherited from Control) | Retrieves the form that the control is on.
Focus (inherited from Control) | Sets input focus to the control.
GetChildAtPoint (inherited from Control) | Retrieves the child control that is located at the specified coordinates.
GetContainerControl (inherited from Control) | Returns the next ContainerControl up the control's chain of parent controls.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetNextControl (inherited from Control) | Retrieves the next control forward or back in the tab order of child controls.
GetType (inherited from Object) | Gets the Type of the current instance.
Hide (inherited from Control) | Conceals the control from the user.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Invalidate (inherited from Control) | Overloaded. Invalidates the specified region of the control (adds it to the control's update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the control.
Invoke (inherited from Control) | Overloaded. Executes the specified delegate, on the thread that owns the control's underlying window handle, with the specified list of arguments.
PerformLayout (inherited from Control) | Overloaded. Forces the control to apply layout logic to all its child controls.
PointToClient (inherited from Control) | Computes the location of the specified screen point into client coordinates.
PointToScreen (inherited from Control) | Computes the location of the specified client point into screen coordinates.
PreProcessMessage (inherited from Control) | Preprocesses input messages within the message loop before they are dispatched.
PrintCursorLine | Sends a copy of the line the cursor is currently on to the printer.
PrintScreen | Sends a copy of the display screen to the printer.
PrintSelectedText | Sends a copy of the currently selected text to the printer.
RectangleToClient (inherited from Control) | Computes the size and location of the specified screen rectangle in client coordinates.
RectangleToScreen (inherited from Control) | Computes the size and location of the specified client rectangle in screen coordinates.
Refresh | Refreshes the screen using current properties.
ResetBackColor (inherited from Control) | Resets the BackColor property to its default value.
ResetBindings (inherited from Control) | Resets the DataBindings property to its default value.
ResetCursor (inherited from Control) | Resets the Cursor property to its default value.
ResetFont (inherited from Control) | Resets the Fontproperty to its default value.
ResetForeColor (inherited from Control) | Resets the ForeColor property to its default value.
ResetImeMode (inherited from Control) | Resets the ImeMode property to its default value.
ResetRightToLeft (inherited from Control) | Resets the RightToLeft property to its default value.
ResetText (inherited from Control) | Resets the Text property to its default value.
Resize | Resizes the screen using current properties.
ResumeLayout (inherited from Control) | Overloaded. Resumes normal layout logic.
Scale (inherited from Control) | Overloaded. Scales the control and any child controls to the specified ratio.
ScrapeCells | Overloaded. Retrieves information about the cells in the specified range.
ScrapeHtml | Overloaded. Returns an HTML representation of the VT data.
ScrapeText | Overloaded. Retrieves text (minus escape characters) from the Vt display.
Select (inherited from Control) | Activates the control.
SelectNextControl (inherited from Control) | Activates the next control.
SendToBack (inherited from Control) | Sends the control to the back of the z-order.
SetBounds (inherited from Control) | Overloaded. Sets the bounds of the control to the specified location and size.
SetDefaultFont | Resets the font to its default value and applies the size change specified.
Show (inherited from Control) | Displays the control to the user.
SuspendLayout (inherited from Control) | Temporarily suspends the layout logic for the control.
ToString (inherited from Component) |
Update (inherited from Control) | Causes the control to redraw the invalidated regions within its client area.
Write | Overloaded. Displays the data contained within a byte array in the Vt window and interprets all escape sequences.

Public Instance Events

AutoRepeatChanged | Raised when the host sends an instruction which changes the value of the Vt.AutoRepeat property.
AutoWrapChanged | Raised when the host sends an instruction which changes the value of the Vt.AutoWrap property.
BackColorChanged (inherited from Control) | Occurs when the value of the BackColor property changes.
BackgroundImageChanged (inherited from Control) | Occurs when the value of the BackgroundImage property changes.
BindingContextChanged (inherited from Control) | Occurs when the value of the BindingContext property changes.
CausesValidationChanged (inherited from Control) | Occurs when the value of the CausesValidation property changes.
ChangeUICues (inherited from Control) | Occurs when the focus or keyboard user interface (UI) cues change.
Click (inherited from Control) | Occurs when the control is clicked.
ContextMenuChanged (inherited from Control) | Occurs when the value of the ContextMenu property changes.
ControlAdded (inherited from Control) | Occurs when a new control is added to the ControlCollection .
ControlRemoved (inherited from Control) | Occurs when a control is removed from the ControlCollection .
CursorChanged (inherited from Control) | Occurs when the value of the Cursor property changes.
CursorKeysChanged | Raised when the host sends an instruction which changes the value of the Vt.CursorKeys property.
CursorPositionChanged | Raised when the host sends an instruction which changes the value of the Vt.CursorPosition property.
Disposed (inherited from Component) | Adds an event handler to listen to the Disposed event on the component.
DockChanged (inherited from Control) | Occurs when the value of the Dock property changes.
DoubleClick (inherited from Control) | Occurs when the control is double-clicked.
DragDrop (inherited from Control) | Occurs when a drag-and-drop operation is completed.
DragEnter (inherited from Control) | Occurs when an object is dragged into the control's bounds.
DragLeave (inherited from Control) | Occurs when an object is dragged out of the control's bounds.
DragOver (inherited from Control) | Occurs when an object is dragged over the control's bounds.
EnabledChanged (inherited from Control) | Occurs when the Enabled property value has changed.
Enter (inherited from Control) | Occurs when the control is entered.
FontChanged (inherited from Control) | Occurs when the Font property value changes.
ForeColorChanged (inherited from Control) | Occurs when the ForeColor property value changes.
GiveFeedback (inherited from Control) | Occurs during a drag operation.
GotFocus (inherited from Control) | Occurs when the control receives focus.
HandleCreated (inherited from Control) | Occurs when a handle is created for the control.
HandleDestroyed (inherited from Control) | Occurs when the control's handle is in the process of being destroyed.
HelpRequested (inherited from Control) | Occurs when the user requests help for a control.
ImeModeChanged (inherited from Control) | Occurs when the ImeMode property has changed.
Invalidated (inherited from Control) | Occurs when a control's display requires redrawing.
InverseChanged | Raised when the host sends an instruction which changes the value of the Vt.Inverse property.
KeyDown | Raised when the user presses a key.
KeyPadChanged | Raised when the host sends an instruction which changes the value of the Vt.KeyPad property.
KeyPress | Raised when the user presses a key.
KeyUp (inherited from Control) | Occurs when a key is released while the control has focus.
Layout (inherited from Control) | Occurs when a control should reposition its child controls.
Leave (inherited from Control) | Occurs when the input focus leaves the control.
Line | Raised when the cursor in the VT changes rows as the result of a new line.
LocalEchoChanged | Raised when the host sends an instruction which changes the value of the Vt.LocalEcho property.
LocationChanged (inherited from Control) | Occurs when the Location property value has changed.
LostFocus (inherited from Control) | Occurs when the control loses focus.
MouseDown (inherited from Control) | Occurs when the mouse pointer is over the control and a mouse button is pressed.
MouseEnter (inherited from Control) | Occurs when the mouse pointer enters the control.
MouseHover (inherited from Control) | Occurs when the mouse pointer hovers over the control.
MouseLeave (inherited from Control) | Occurs when the mouse pointer leaves the control.
MouseMove (inherited from Control) | Occurs when the mouse pointer is moved over the control.
MouseUp (inherited from Control) | Occurs when the mouse pointer is over the control and a mouse button is released.
MouseWheel (inherited from Control) | Occurs when the mouse wheel moves while the control has focus.
Move (inherited from Control) | Occurs when the control is moved.
NewLineChanged | Raised when the host sends an instruction which changes the value of the Vt.NewLine property.
Paint (inherited from Control) | Occurs when the control is redrawn.
ParentChanged (inherited from Control) | Occurs when the Parent property value changes.
PrintChanged | Raised when the host sends an instruction which changes the value of the Vt.Print property.
QueryAccessibilityHelp (inherited from Control) | Occurs when AccessibleObject is providing help to accessibility applications.
QueryContinueDrag (inherited from Control) | Occurs during a drag-and-drop operation and allows the drag source to determine whether the drag-and-drop operation should be canceled.
Resize (inherited from Control) | Occurs when the control is resized.
RightToLeftChanged (inherited from Control) | Occurs when the RightToLeft property value changes.
ScreenSizeChanged | Raised when the host sends an instruction which changes the value of the Vt.ScreenSize property.
ScrollTypeChanged | Raised when the host sends an instruction which changes the value of the Vt.ScrollType property.
SizeChanged (inherited from Control) | Occurs when the Size property value changes.
StyleChanged (inherited from Control) | Occurs when the control style changes.
SystemColorsChanged (inherited from Control) | Occurs when the system colors change.
TabIndexChanged (inherited from Control) | Occurs when the TabIndex property value changes.
TabsChanged | Raised when the host sends an instruction which changes the value of the Vt.Tabs property.
TabStopChanged (inherited from Control) | Occurs when the TabStop property value changes.
TerminalTypeChanged | Raised when the host sends an instruction which changes the value of the Vt.TerminalType property.
TextChanged (inherited from Control) | Occurs when the Text property value changes.
Validated (inherited from Control) | Occurs when the control is finished validating.
Validating (inherited from Control) | Occurs when the control is validating.
VisibleChanged (inherited from Control) | Occurs when the Visible property value changes.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt Constructor

Initializes a new instance of Vt.

Overload List

Initializes a new instance of Vt.

public Vt();

Initializes a new instance of Vt.

public Vt(IContainer);

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt Constructor ()

Initializes a new instance of Vt.

[Visual Basic]
Overloads Public Sub New()
[C#]
public Vt();

Remarks

The default constructor initializes a new instance of the Vt control. The control will be provided with the following default values:

The following table shows initial property values for an instance of Vt.

Property | Initial Value
Vt.AcceptTabs | true
Vt.Answer | empty string
Vt.AutoRepeat | true
Vt.AutoWrap | true
Vt.BackColor | KnownColor.Window
Vt.Bell | true
Vt.BlinkIntensity | 50
Vt.BoldColor | KnownColor.WindowText
Vt.BufferRows | 72
Vt.CursorKeys | CursorKeys.Normal
Vt.CursorPosition | (0, 0)
Vt.CursorStyle | CursorStyle.Block
Vt.ForeColor | KnownColor.WindowText
Vt.Inverse | false
Vt.Keypad | KeyPad.Numeric
Vt.LocalEcho | false
Vt.Margin | (4, 4)
Vt.NewLine | NewLine.Cr
Vt.NormalIntensity | 75
Vt.PrintPassthrough | false
Vt.Scroll | ScrollType.Smooth
Vt.StatusLine | empty string
Vt.Tabs | empty string
Vt.TerminalType | TerminalType.Vt320_7
Vt.UseDefaultPrinter | true

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace | Vt Constructor Overload List


Vt Constructor (IContainer)

Initializes a new instance of Vt.

[Visual Basic]
Overloads Public Sub New( _
ByVal container As IContainer _
)
[C#]
public Vt(
IContainer container
);

Parameters

container
The IContainer which contains the object.

Remarks

The default constructor initializes a new instance of the Vt control. The control will be provided with the following default values:

The following table shows initial property values for an instance of Vt.

Property | Initial Value
Vt.AcceptTabs | true
Vt.Answer | empty string
Vt.AutoRepeat | true
Vt.AutoWrap | true
Vt.BackColor | KnownColor.Window
Vt.Bell | true
Vt.BlinkIntensity | 50
Vt.BoldColor | KnownColor.WindowText
Vt.BufferRows | 72
Vt.CursorKeys | CursorKeys.Normal
Vt.CursorPosition | (0, 0)
Vt.CursorStyle | CursorStyle.Block
Vt.ForeColor | KnownColor.WindowText
Vt.Inverse | false
Vt.Keypad | KeyPad.Numeric
Vt.LocalEcho | false
Vt.Margin | (4, 4)
Vt.NewLine | NewLine.Cr
Vt.NormalIntensity | 75
Vt.PrintPassthrough | false
Vt.Scroll | ScrollType.Smooth
Vt.StatusLine | empty string
Vt.Tabs | empty string
Vt.TerminalType | TerminalType.Vt320_7
Vt.UseDefaultPrinter | true

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace | Vt Constructor Overload List


Vt Properties

The properties of the Vt class are listed below. For a complete list of Vt class members, see the Vt Members topic.

Public Instance Properties

AcceptTabs | Gets or sets whether to retain focus when the tab key is used.
AccessibilityObject (inherited from Control) | Gets the AccessibleObject assigned to the control.
AccessibleDefaultActionDescription (inherited from Control) | Gets or sets the default action description of the control for use by accessibility client applications.
AccessibleDescription (inherited from Control) | Gets or sets the description of the control used by accessibility client applications.
AccessibleName (inherited from Control) | Gets or sets the name of the control used by accessibility client applications.
AccessibleRole (inherited from Control) | Gets or sets the accessible role of the control
AllowDrop (inherited from Control) | Gets or sets a value indicating whether the control can accept data that the user drags onto it.
Anchor (inherited from Control) | Gets or sets which edges of the control are anchored to the edges of its container.
Answer | Gets or sets a string expression to be sent by the control whenever an ENQ is received.
AutoRepeat | Gets or sets a value that determines whether depressed keys generate more than one character.
AutoWrap | Gets or sets a value that indicates whether display text stops at the last column or wraps to the next line when a line contains more data than can fit on one row.
BackColor | Gets or sets the background color for the control.
BackgroundImage (inherited from Control) | Gets or sets the background image displayed in the control.
Bell | Gets or sets a value that determines whether an audio bell is enabled.
BindingContext (inherited from Control) | Gets or sets the BindingContext for the control.
BlinkIntensity | Gets or sets the "brightness" of blinking text.
BoldColor | Gets or sets the color of bold text.
Bottom (inherited from Control) | Gets the distance between the bottom edge of the control and the top edge of its container's client area.
Bounds (inherited from Control) | Gets or sets the size and location of the control including its nonclient elements.
BufferRows | Gets or sets the number of rows stored in the scrollback buffer.
CanFocus (inherited from Control) | Gets a value indicating whether the control can receive focus.
CanSelect (inherited from Control) | Gets a value indicating whether the control can be selected.
CausesValidation (inherited from Control) | Gets or sets a value indicating whether the control causes validation to be performed on any controls that require validation when it receives focus.
ClientRectangle (inherited from Control) | Gets the rectangle that represents the client area of the control.
ClientSize (inherited from Control) | Gets or sets the height and width of the client area of the control.
CompanyName (inherited from Control) | Gets the name of the company or creator of the application containing the control.
Container (inherited from Component) | Gets the IContainer that contains the Component.
ContainsFocus (inherited from Control) | Gets a value indicating whether the control, or one of its child controls, currently has the input focus.
ContextMenu (inherited from Control) | Gets or sets the shortcut menu associated with the control.
Controls (inherited from Control) | Gets the collection of controls contained within the control.
Created (inherited from Control) | Gets a value indicating whether the control has been created.
Cursor (inherited from Control) | Gets or sets the cursor that is displayed when the mouse pointer is over the control.
CursorKeys | Gets or sets a value that determines whether the cursor keys send ANSI cursor control sequences (up, down, left, right) or application control sequences.
CursorStyle | Gets or sets a value which indicates the cursor style.
DataBindings (inherited from Control) | Gets the data bindings for the control.
DisplayRectangle (inherited from Control) | Gets the rectangle that represents the display area of the control.
Disposing (inherited from Control) | Gets a value indicating whether the control is in the process of being disposed of.
Dock (inherited from Control) | Gets or sets which edge of the parent container a control is docked to.
Enabled (inherited from Control) | Gets or sets a value indicating whether the control can respond to user interaction.
Focused (inherited from Control) | Gets a value indicating whether the control has input focus.
Font | NEVER USE THE VT.FONT PROPERTY. USE VT.FONTEX INSTEAD.
FontEx | Gets or sets the font used in the display of the control.
ForeColor | Gets or sets the foreground color for the control.
Handle (inherited from Control) | Gets the window handle that the control is bound to.
HasChildren (inherited from Control) | Gets a value indicating whether the control contains one or more child controls.
Height (inherited from Control) | Gets or sets the height of the control.
ImeMode (inherited from Control) | Gets or sets the Input Method Editor (IME) mode of the control.
Inverse | Gets or sets a value that determines whether the foreground and background colors are switched.
InvokeRequired (inherited from Control) | Gets a value indicating whether the caller must call an invoke method when making method calls to the control because the caller is on a different thread than the one the control was created on.
IsAccessible (inherited from Control) | Gets or sets a value indicating whether the control is visible to accessibility applications.
IsDisposed (inherited from Control) | Gets a value indicating whether the control has been disposed of.
IsHandleCreated (inherited from Control) | Gets a value indicating whether the control has a handle associated with it.
KeyPad | Gets or sets a value that determines whether the keypad sends ASCII characters or escape sequences.
Left (inherited from Control) | Gets or sets the x-coordinate of a control's left edge in pixels.
LocalEcho | Gets or sets a value which controls whether or not key presses are displayed on the Vt window.
Location (inherited from Control) | Gets or sets the coordinates of the upper-left corner of the control relative to the upper-left corner of its container.
Margin | Gets or sets a Size object which determines the amount of "buffer" space around the Vt content on the window.
Name (inherited from Control) | Gets or sets the name of the control.
NationalCharSet | Gets or sets the national character set for use in VT220 7-bit or VT320 7-bit emulation modes to display special characters that normally require 8-bit emulation mode.
NewLine | Gets or sets the end-of-line character sequence to use.
NormalIntensity | Gets or sets the "brightness" of normal text.
Parent (inherited from Control) | Gets or sets the parent container of the control.
Print | Gets or sets a PrintType specifying how printing should occur.
PrintPassthrough | Gets or sets a value that determines if printing bypasses the normal printer drivers and prints directly to the printer port.
ProductName (inherited from Control) | Gets the product name of the assembly containing the control.
ProductVersion (inherited from Control) | Gets the version of the assembly containing the control.
RecreatingHandle (inherited from Control) | Gets a value indicating whether the control is currently re-creating its handle.
Region (inherited from Control) | Gets or sets the window region associated with the control.
Right (inherited from Control) | Gets the distance between the right edge of the control and the left edge of its container.
RightToLeft (inherited from Control) | Gets or sets a value indicating whether control's elements are aligned to support locales using right-to-left fonts.
ScreenSize | Gets or sets the screen size (number of columns and rows) used by the Vt window.
ScrollType | Gets or sets a value that determines whether to use jump scrolling or smooth scrolling in the display screen.
SelectedText | Gets the currently selected text.
SelectionLength | Gets or sets the length of the number of characters selected.
SelectionStart | Gets or sets the starting index of the characters currently selected.
Site (inherited from Control) | Gets or sets the site of the control.
Size (inherited from Control) | Gets or sets the height and width of the control.
StatusLine | Gets or sets a value that indicates whether a 25th line is displayed as a status line when in VT320 7-bit or 8-bit mode.
TabIndex (inherited from Control) | Gets or sets the tab order of the control within its container.
Tabs | Gets or sets a list of comma-delimited tab positions.
TabStop (inherited from Control) | Gets or sets a value indicating whether the user can give the focus to this control using the TAB key.
Tag (inherited from Control) | Gets or sets the object that contains data about the control.
Telnet | Gets the internal Telnet control to use for online communications.
TerminalType | Gets or sets the terminal type to emulate.
Text | DO NOT USE THE TEXT PROPERTY. USE THE WRITE METHOD TO ADD TEXT TO THE VT AND THE SCRAPETEXT METHOD TO GET TEXT FROM THE VT.
TextLength | Returns the length of the data in the Vt window.
Top (inherited from Control) | Gets or sets the y-coordinate of the control's top edge in pixels.
TopLevelControl (inherited from Control) | Gets the parent control that is not parented by another Windows Forms control. Typically, this is the outermost Form that the control is contained in.
UseDefaultPrinter | Gets or sets a value which indicates whether the system default printer or a user-selected printer is used.
Visible (inherited from Control) | Gets or sets a value indicating whether the control is displayed.
Width (inherited from Control) | Gets or sets the width of the control.
WindowTarget (inherited from Control) |

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.AcceptTabs Property

Gets or sets whether to retain focus when the tab key is used.

[Visual Basic]
Public Property AcceptTabs As Boolean
[C#]
public bool AcceptTabs {get; set;}

Property Value

true if the Vt control should retain focus when the tab key is pressed, false if the tab key should cause the focus to shift to the next control in the tab index. The default value is true.

Example

[Visual Basic, C#] The following example demonstrates setting many of the simple properties to non-default values.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = False

' Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = False

' Set so lines do not wrap if they are too long.
vt1.AutoWrap = True

' Set backcolor to Red
vt1.BackColor = Color.Red

' Disable bell
vt1.Bell = False

' Set Blink Intensity to 40
vt1.BlinkIntensity = 40

' Set bold text color to Blue
vt1.BoldColor = Color.Blue

' Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application

' Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = New System.Drawing.Point(5, 5)

' Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline

' Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow

' "Swap" the foreground and background colors.
vt1.Inverse = True

' Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application

' Echo any typed keys to the display.
vt1.LocalEcho = True

' Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British

' Set Normal Intensity to 80
vt1.NormalIntensity = 80

' Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = New System.Drawing.Size(70, 20)

' Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump

' Change the size of the control to 250 X 100
vt1.Size = New System.Drawing.Size(250, 100)

' Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30"

' Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = False
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = false;

// Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = false;

// Set so lines do not wrap if they are too long.
vt1.AutoWrap = true;

// Set backcolor to Red
vt1.BackColor = Color.Red;

// Disable bell
vt1.Bell = false;

// Set Blink Intensity to 40
vt1.BlinkIntensity = 40;

// Set bold text color to Blue
vt1.BoldColor = Color.Blue;

// Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application;

// Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = new System.Drawing.Point(5, 5);

// Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline;

// Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow;

// "Swap" the foreground and background colors.
vt1.Inverse = true;

// Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application;

// Echo any typed keys to the display.
vt1.LocalEcho = true;

// Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British;

// Set Normal Intensity to 80
vt1.NormalIntensity = 80;

// Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = new System.Drawing.Size(70, 20);

// Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump;

// Change the size of the control to 250 X 100
vt1.Size = new System.Drawing.Size(250, 100);

// Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30";

// Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = false;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.Answer Property

Gets or sets a string expression to be sent by the control whenever an ENQ is received.

[Visual Basic]
Public Property Answer As String
[C#]
public string Answer {get; set;}

Property Value

A string representing the data to send when an ENQ request is received.

Remarks

A server may send an ENQ command to a client, requesting a response. The value of this property is sent as the response. This property defaults to an empty string, meaning no response is sent to an ENQ request.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.AutoRepeat Property

Gets or sets a value that determines whether depressed keys generate more than one character.

[Visual Basic]
Public Property AutoRepeat As Boolean
[C#]
public bool AutoRepeat {get; set;}

Property Value

true if a depressed key should generate more than one character; false if a depressed key should only generate one character. The default value is true.

Remarks

When set to False, only a single character is generated when a key is depressed for a time interval; otherwise, multiple characters are generated until the key is released.

If data is received from the host which causes this property to change, the Vt.AutoRepeatChanged event is raised.

Example

[Visual Basic, C#] The following example demonstrates setting many of the simple properties to non-default values.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = False

' Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = False

' Set so lines do not wrap if they are too long.
vt1.AutoWrap = True

' Set backcolor to Red
vt1.BackColor = Color.Red

' Disable bell
vt1.Bell = False

' Set Blink Intensity to 40
vt1.BlinkIntensity = 40

' Set bold text color to Blue
vt1.BoldColor = Color.Blue

' Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application

' Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = New System.Drawing.Point(5, 5)

' Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline

' Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow

' "Swap" the foreground and background colors.
vt1.Inverse = True

' Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application

' Echo any typed keys to the display.
vt1.LocalEcho = True

' Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British

' Set Normal Intensity to 80
vt1.NormalIntensity = 80

' Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = New System.Drawing.Size(70, 20)

' Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump

' Change the size of the control to 250 X 100
vt1.Size = New System.Drawing.Size(250, 100)

' Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30"

' Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = False
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = false;

// Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = false;

// Set so lines do not wrap if they are too long.
vt1.AutoWrap = true;

// Set backcolor to Red
vt1.BackColor = Color.Red;

// Disable bell
vt1.Bell = false;

// Set Blink Intensity to 40
vt1.BlinkIntensity = 40;

// Set bold text color to Blue
vt1.BoldColor = Color.Blue;

// Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application;

// Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = new System.Drawing.Point(5, 5);

// Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline;

// Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow;

// "Swap" the foreground and background colors.
vt1.Inverse = true;

// Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application;

// Echo any typed keys to the display.
vt1.LocalEcho = true;

// Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British;

// Set Normal Intensity to 80
vt1.NormalIntensity = 80;

// Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = new System.Drawing.Size(70, 20);

// Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump;

// Change the size of the control to 250 X 100
vt1.Size = new System.Drawing.Size(250, 100);

// Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30";

// Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = false;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.AutoWrap Property

Gets or sets a value that indicates whether display text stops at the last column or wraps to the next line when a line contains more data than can fit on one row.

[Visual Basic]
Public Property AutoWrap As Boolean
[C#]
public bool AutoWrap {get; set;}

Property Value

true if text should wrap when a line contains more data then can fit on a row; false otherwise. The default value is true.

Remarks

If data is received from the host which causes this property to change, the Vt.AutoWrapChanged event is raised.

Example

[Visual Basic, C#] The following example demonstrates setting many of the simple properties to non-default values.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = False

' Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = False

' Set so lines do not wrap if they are too long.
vt1.AutoWrap = True

' Set backcolor to Red
vt1.BackColor = Color.Red

' Disable bell
vt1.Bell = False

' Set Blink Intensity to 40
vt1.BlinkIntensity = 40

' Set bold text color to Blue
vt1.BoldColor = Color.Blue

' Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application

' Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = New System.Drawing.Point(5, 5)

' Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline

' Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow

' "Swap" the foreground and background colors.
vt1.Inverse = True

' Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application

' Echo any typed keys to the display.
vt1.LocalEcho = True

' Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British

' Set Normal Intensity to 80
vt1.NormalIntensity = 80

' Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = New System.Drawing.Size(70, 20)

' Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump

' Change the size of the control to 250 X 100
vt1.Size = New System.Drawing.Size(250, 100)

' Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30"

' Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = False
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = false;

// Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = false;

// Set so lines do not wrap if they are too long.
vt1.AutoWrap = true;

// Set backcolor to Red
vt1.BackColor = Color.Red;

// Disable bell
vt1.Bell = false;

// Set Blink Intensity to 40
vt1.BlinkIntensity = 40;

// Set bold text color to Blue
vt1.BoldColor = Color.Blue;

// Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application;

// Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = new System.Drawing.Point(5, 5);

// Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline;

// Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow;

// "Swap" the foreground and background colors.
vt1.Inverse = true;

// Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application;

// Echo any typed keys to the display.
vt1.LocalEcho = true;

// Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British;

// Set Normal Intensity to 80
vt1.NormalIntensity = 80;

// Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = new System.Drawing.Size(70, 20);

// Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump;

// Change the size of the control to 250 X 100
vt1.Size = new System.Drawing.Size(250, 100);

// Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30";

// Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = false;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.BackColor Property

Gets or sets the background color for the control.

[Visual Basic]
Overrides Public Property BackColor As Color
[C#]
public override System.Drawing.Color BackColor {get; set;}

Property Value

A System.Drawing.Color value.

Remarks

This property defaults to Color.Window.

Example

[Visual Basic, C#] The following example demonstrates setting many of the simple properties to non-default values.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = False

' Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = False

' Set so lines do not wrap if they are too long.
vt1.AutoWrap = True

' Set backcolor to Red
vt1.BackColor = Color.Red

' Disable bell
vt1.Bell = False

' Set Blink Intensity to 40
vt1.BlinkIntensity = 40

' Set bold text color to Blue
vt1.BoldColor = Color.Blue

' Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application

' Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = New System.Drawing.Point(5, 5)

' Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline

' Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow

' "Swap" the foreground and background colors.
vt1.Inverse = True

' Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application

' Echo any typed keys to the display.
vt1.LocalEcho = True

' Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British

' Set Normal Intensity to 80
vt1.NormalIntensity = 80

' Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = New System.Drawing.Size(70, 20)

' Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump

' Change the size of the control to 250 X 100
vt1.Size = New System.Drawing.Size(250, 100)

' Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30"

' Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = False
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = false;

// Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = false;

// Set so lines do not wrap if they are too long.
vt1.AutoWrap = true;

// Set backcolor to Red
vt1.BackColor = Color.Red;

// Disable bell
vt1.Bell = false;

// Set Blink Intensity to 40
vt1.BlinkIntensity = 40;

// Set bold text color to Blue
vt1.BoldColor = Color.Blue;

// Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application;

// Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = new System.Drawing.Point(5, 5);

// Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline;

// Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow;

// "Swap" the foreground and background colors.
vt1.Inverse = true;

// Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application;

// Echo any typed keys to the display.
vt1.LocalEcho = true;

// Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British;

// Set Normal Intensity to 80
vt1.NormalIntensity = 80;

// Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = new System.Drawing.Size(70, 20);

// Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump;

// Change the size of the control to 250 X 100
vt1.Size = new System.Drawing.Size(250, 100);

// Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30";

// Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = false;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.Bell Property

Gets or sets a value that determines whether an audio bell is enabled.

[Visual Basic]
Public Property Bell As Boolean
[C#]
public bool Bell {get; set;}

Property Value

true if the BEL character should cause the bell to sound; false otherwise. The default value is true.

Remarks

The ASCII BEL character causes the system bell to sound. Such actions as attempting to scroll past the scroll range also cause the bell to sound.

Example

[Visual Basic, C#] The following example demonstrates setting many of the simple properties to non-default values.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = False

' Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = False

' Set so lines do not wrap if they are too long.
vt1.AutoWrap = True

' Set backcolor to Red
vt1.BackColor = Color.Red

' Disable bell
vt1.Bell = False

' Set Blink Intensity to 40
vt1.BlinkIntensity = 40

' Set bold text color to Blue
vt1.BoldColor = Color.Blue

' Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application

' Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = New System.Drawing.Point(5, 5)

' Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline

' Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow

' "Swap" the foreground and background colors.
vt1.Inverse = True

' Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application

' Echo any typed keys to the display.
vt1.LocalEcho = True

' Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British

' Set Normal Intensity to 80
vt1.NormalIntensity = 80

' Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = New System.Drawing.Size(70, 20)

' Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump

' Change the size of the control to 250 X 100
vt1.Size = New System.Drawing.Size(250, 100)

' Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30"

' Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = False
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = false;

// Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = false;

// Set so lines do not wrap if they are too long.
vt1.AutoWrap = true;

// Set backcolor to Red
vt1.BackColor = Color.Red;

// Disable bell
vt1.Bell = false;

// Set Blink Intensity to 40
vt1.BlinkIntensity = 40;

// Set bold text color to Blue
vt1.BoldColor = Color.Blue;

// Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application;

// Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = new System.Drawing.Point(5, 5);

// Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline;

// Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow;

// "Swap" the foreground and background colors.
vt1.Inverse = true;

// Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application;

// Echo any typed keys to the display.
vt1.LocalEcho = true;

// Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British;

// Set Normal Intensity to 80
vt1.NormalIntensity = 80;

// Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = new System.Drawing.Size(70, 20);

// Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump;

// Change the size of the control to 250 X 100
vt1.Size = new System.Drawing.Size(250, 100);

// Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30";

// Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = false;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.BlinkIntensity Property

Gets or sets the "brightness" of blinking text.

[Visual Basic]
Public Property BlinkIntensity As Integer
[C#]
public int BlinkIntensity {get; set;}

Property Value

An integer representing the intensity of blinking text. The default value is 0.

Remarks

The valid range is 0 to 100. When set to 0, text will go off and on during the blink cycle. When set to 100 blinking is effectively "turned off". When set to a value in the middle, blinking text will appear dimmer than usual.

Example

[Visual Basic, C#] The following example demonstrates setting many of the simple properties to non-default values.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = False

' Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = False

' Set so lines do not wrap if they are too long.
vt1.AutoWrap = True

' Set backcolor to Red
vt1.BackColor = Color.Red

' Disable bell
vt1.Bell = False

' Set Blink Intensity to 40
vt1.BlinkIntensity = 40

' Set bold text color to Blue
vt1.BoldColor = Color.Blue

' Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application

' Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = New System.Drawing.Point(5, 5)

' Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline

' Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow

' "Swap" the foreground and background colors.
vt1.Inverse = True

' Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application

' Echo any typed keys to the display.
vt1.LocalEcho = True

' Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British

' Set Normal Intensity to 80
vt1.NormalIntensity = 80

' Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = New System.Drawing.Size(70, 20)

' Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump

' Change the size of the control to 250 X 100
vt1.Size = New System.Drawing.Size(250, 100)

' Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30"

' Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = False
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = false;

// Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = false;

// Set so lines do not wrap if they are too long.
vt1.AutoWrap = true;

// Set backcolor to Red
vt1.BackColor = Color.Red;

// Disable bell
vt1.Bell = false;

// Set Blink Intensity to 40
vt1.BlinkIntensity = 40;

// Set bold text color to Blue
vt1.BoldColor = Color.Blue;

// Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application;

// Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = new System.Drawing.Point(5, 5);

// Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline;

// Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow;

// "Swap" the foreground and background colors.
vt1.Inverse = true;

// Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application;

// Echo any typed keys to the display.
vt1.LocalEcho = true;

// Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British;

// Set Normal Intensity to 80
vt1.NormalIntensity = 80;

// Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = new System.Drawing.Size(70, 20);

// Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump;

// Change the size of the control to 250 X 100
vt1.Size = new System.Drawing.Size(250, 100);

// Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30";

// Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = false;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.BoldColor Property

Gets or sets the color of bold text.

[Visual Basic]
Public Property BoldColor As Color
[C#]
public System.Drawing.Color BoldColor {get; set;}

Property Value

A System.Drawing.Color value specifying the color of bold text.

Remarks

The default value is green (R=0, G=128, B=0).

Example

[Visual Basic, C#] The following example demonstrates setting many of the simple properties to non-default values.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = False

' Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = False

' Set so lines do not wrap if they are too long.
vt1.AutoWrap = True

' Set backcolor to Red
vt1.BackColor = Color.Red

' Disable bell
vt1.Bell = False

' Set Blink Intensity to 40
vt1.BlinkIntensity = 40

' Set bold text color to Blue
vt1.BoldColor = Color.Blue

' Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application

' Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = New System.Drawing.Point(5, 5)

' Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline

' Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow

' "Swap" the foreground and background colors.
vt1.Inverse = True

' Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application

' Echo any typed keys to the display.
vt1.LocalEcho = True

' Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British

' Set Normal Intensity to 80
vt1.NormalIntensity = 80

' Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = New System.Drawing.Size(70, 20)

' Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump

' Change the size of the control to 250 X 100
vt1.Size = New System.Drawing.Size(250, 100)

' Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30"

' Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = False
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = false;

// Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = false;

// Set so lines do not wrap if they are too long.
vt1.AutoWrap = true;

// Set backcolor to Red
vt1.BackColor = Color.Red;

// Disable bell
vt1.Bell = false;

// Set Blink Intensity to 40
vt1.BlinkIntensity = 40;

// Set bold text color to Blue
vt1.BoldColor = Color.Blue;

// Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application;

// Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = new System.Drawing.Point(5, 5);

// Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline;

// Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow;

// "Swap" the foreground and background colors.
vt1.Inverse = true;

// Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application;

// Echo any typed keys to the display.
vt1.LocalEcho = true;

// Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British;

// Set Normal Intensity to 80
vt1.NormalIntensity = 80;

// Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = new System.Drawing.Size(70, 20);

// Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump;

// Change the size of the control to 250 X 100
vt1.Size = new System.Drawing.Size(250, 100);

// Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30";

// Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = false;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.BufferRows Property

Gets or sets the number of rows stored in the scrollback buffer.

[Visual Basic]
Public Property BufferRows As Integer
[C#]
public int BufferRows {get; set;}

Property Value

An integer specifying the number of rows stored in the scrollback buffer.

Remarks

The default value is 72, which means by default the Vt control will store 72 rows of data that has "scrolled" off of the screen. Set this property to 0 to disable the scrollback buffer.

Often, you have to take the size of the scrollback buffer into account when interacting with the Vt control. For example, if you wish to select the first 10 characters of DISPLAYED text, setting Vt.SelectionStart to 0 and Vt.SelectionLength to 10 will cause the first 10 characters of the SCROLLBACK buffer to be displayed, not the desired result. You must perform a small calculation to to subtract the characters in the buffer from the selected text, for example:

            vt1.SelectionStart = vt1.BufferRows * (vt1.ScreenSize.Width + 2);
            vt1.SelectionLength = 10;

Example

[Visual Basic, C#] The following example demonstrates selecting the text on the display window. The display window is calculated using BufferRows and ScreenSize. Note, this does the exact same thing as PrintScreen, and is just shown to demonstrate how to calculate where text is on the Vt display.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Select the display window.
vt1.SelectionStart = vt1.BufferRows * (vt1.ScreenSize.Width + 2)
vt1.SelectionLength = vt1.ScreenSize.Height * (vt1.ScreenSize.Width + 2)

' Display the selected text
MessageBox.Show("Selected Text = " + vt1.SelectedText)

' Print the selected text
vt1.PrintSelectedText()

' ...

' As an alternative to all of the above code, you can simply use...
vt1.PrintScreen()
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Select the display window.
vt1.SelectionStart = vt1.BufferRows * (vt1.ScreenSize.Width + 2);
vt1.SelectionLength = vt1.ScreenSize.Height * (vt1.ScreenSize.Width + 2);

// Display the selected text
MessageBox.Show("Selected Text = " + vt1.SelectedText);

// Print the selected text
vt1.PrintSelectedText();

// ...

// As an alternative to all of the above code, you can simply use...
vt1.PrintScreen();

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.CursorKeys Property

Gets or sets a value that determines whether the cursor keys send ANSI cursor control sequences (up, down, left, right) or application control sequences.

[Visual Basic]
Public Property CursorKeys As CursorKeys
[C#]
public CursorKeys CursorKeys {get; set;}

Property Value

A CursorKeys value. The default value is CursorKeys.Normal.

Remarks

If data is received from the host which causes this property to change, the Vt.CursorKeysChanged event is raised.

Example

[Visual Basic, C#] The following example demonstrates setting many of the simple properties to non-default values.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = False

' Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = False

' Set so lines do not wrap if they are too long.
vt1.AutoWrap = True

' Set backcolor to Red
vt1.BackColor = Color.Red

' Disable bell
vt1.Bell = False

' Set Blink Intensity to 40
vt1.BlinkIntensity = 40

' Set bold text color to Blue
vt1.BoldColor = Color.Blue

' Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application

' Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = New System.Drawing.Point(5, 5)

' Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline

' Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow

' "Swap" the foreground and background colors.
vt1.Inverse = True

' Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application

' Echo any typed keys to the display.
vt1.LocalEcho = True

' Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British

' Set Normal Intensity to 80
vt1.NormalIntensity = 80

' Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = New System.Drawing.Size(70, 20)

' Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump

' Change the size of the control to 250 X 100
vt1.Size = New System.Drawing.Size(250, 100)

' Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30"

' Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = False
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = false;

// Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = false;

// Set so lines do not wrap if they are too long.
vt1.AutoWrap = true;

// Set backcolor to Red
vt1.BackColor = Color.Red;

// Disable bell
vt1.Bell = false;

// Set Blink Intensity to 40
vt1.BlinkIntensity = 40;

// Set bold text color to Blue
vt1.BoldColor = Color.Blue;

// Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application;

// Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = new System.Drawing.Point(5, 5);

// Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline;

// Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow;

// "Swap" the foreground and background colors.
vt1.Inverse = true;

// Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application;

// Echo any typed keys to the display.
vt1.LocalEcho = true;

// Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British;

// Set Normal Intensity to 80
vt1.NormalIntensity = 80;

// Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = new System.Drawing.Size(70, 20);

// Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump;

// Change the size of the control to 250 X 100
vt1.Size = new System.Drawing.Size(250, 100);

// Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30";

// Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = false;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.CursorStyle Property

Gets or sets a value which indicates the cursor style.

[Visual Basic]
Public Property CursorStyle As CursorStyle
[C#]
public CursorStyle CursorStyle {get; set;}

Property Value

A CursorStyle value. The default value is CursorStyle.Block.

Example

[Visual Basic, C#] The following example demonstrates setting many of the simple properties to non-default values.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = False

' Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = False

' Set so lines do not wrap if they are too long.
vt1.AutoWrap = True

' Set backcolor to Red
vt1.BackColor = Color.Red

' Disable bell
vt1.Bell = False

' Set Blink Intensity to 40
vt1.BlinkIntensity = 40

' Set bold text color to Blue
vt1.BoldColor = Color.Blue

' Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application

' Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = New System.Drawing.Point(5, 5)

' Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline

' Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow

' "Swap" the foreground and background colors.
vt1.Inverse = True

' Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application

' Echo any typed keys to the display.
vt1.LocalEcho = True

' Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British

' Set Normal Intensity to 80
vt1.NormalIntensity = 80

' Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = New System.Drawing.Size(70, 20)

' Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump

' Change the size of the control to 250 X 100
vt1.Size = New System.Drawing.Size(250, 100)

' Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30"

' Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = False
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = false;

// Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = false;

// Set so lines do not wrap if they are too long.
vt1.AutoWrap = true;

// Set backcolor to Red
vt1.BackColor = Color.Red;

// Disable bell
vt1.Bell = false;

// Set Blink Intensity to 40
vt1.BlinkIntensity = 40;

// Set bold text color to Blue
vt1.BoldColor = Color.Blue;

// Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application;

// Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = new System.Drawing.Point(5, 5);

// Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline;

// Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow;

// "Swap" the foreground and background colors.
vt1.Inverse = true;

// Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application;

// Echo any typed keys to the display.
vt1.LocalEcho = true;

// Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British;

// Set Normal Intensity to 80
vt1.NormalIntensity = 80;

// Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = new System.Drawing.Size(70, 20);

// Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump;

// Change the size of the control to 250 X 100
vt1.Size = new System.Drawing.Size(250, 100);

// Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30";

// Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = false;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.Font Property

NEVER USE THE VT.FONT PROPERTY. USE VT.FONTEX INSTEAD.

[Visual Basic]
Overrides Public Property Font As Font
[C#]
public override System.Drawing.Font Font {get; set;}

Property Value

Always throws a compiler Exception.

Remarks

This property was obsoleted in favor of Vt.FontEx. The Vt.Font property is a System.Drawing.Font object, which does not support raster fonts. The Vt control includes a Dart.PowerTCP.Emulation.Font object (exposed by Vt.FontEx) which does support raster fonts.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.FontEx Property

Gets or sets the font used in the display of the control.

[Visual Basic]
Public Property FontEx As Font
[C#]
public Font FontEx {get; set;}

Property Value

A Dart.PowerTCP.Emulation.Font object.

Remarks

The FontEx property replaces the Font property as the mechanism for setting the font for the control.

The default value is 11-point VT220_ascii font.

Example

[Visual Basic, C#] The following example demonstrates dynamically creating a Font object.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Create a new Font object
Dim f as Dart.PowerTCP.Emulation.Font
f = New Dart.PowerTCP.Emulation.Font("courier", 7.5, FontStyle.Bold + FontStyle.Italic)
vt1.FontEx = f

' Display font info.
textBox1.Text = "Current font" & vbCrLf
textBox1.Text = textBox1.Text & "----------------" & vbCrLf
textBox1.Text = textBox1.Text & "Name: " & vt1.FontEx.Name & vbCrLf
textBox1.Text = textBox1.Text & "Size: " & vt1.FontEx.Size & vbCrLf
textBox1.Text = textBox1.Text & "Bold: " & vt1.FontEx.Bold & vbCrLf
textBox1.Text = textBox1.Text & "Italic: " & vt1.FontEx.Italic & vbCrLf
textBox1.Text = textBox1.Text & "Underline: " & vt1.FontEx.Underline & vbCrLf
textBox1.Text = textBox1.Text & "Strikeout: " & vt1.FontEx.Strikeout & vbCrLf
textBox1.Text = textBox1.Text & "Height: " & vt1.FontEx.Height & vbCrLf
textBox1.Text = textBox1.Text & "Type: " & vt1.FontEx.Type.ToString() & vbCrLF
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Font object
Dart.PowerTCP.Emulation.Font f;
f = new Dart.PowerTCP.Emulation.Font("courier", (float)7.5, FontStyle.Bold | FontStyle.Italic);
vt1.FontEx = f;

// Display font info.
textBox1.Text = "Current font\r\n";
textBox1.Text+= "----------------\r\n";
textBox1.Text+= "Name: " + vt1.FontEx.Name + "\r\n";
textBox1.Text+= "Size: " + vt1.FontEx.Size + "\r\n";
textBox1.Text+= "Bold: " + vt1.FontEx.Bold + "\r\n";
textBox1.Text+= "Italic: " + vt1.FontEx.Italic + "\r\n";
textBox1.Text+= "Underline: " + vt1.FontEx.Underline + "\r\n";
textBox1.Text+= "Strikeout: " + vt1.FontEx.Strikeout + "\r\n";
textBox1.Text+= "Height: " + vt1.FontEx.Height + "\r\n";
textBox1.Text+= "Type: " + vt1.FontEx.Type.ToString() + "\r\n";

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

[Visual Basic, C#] The following example demonstrates using the FontDialog class to set the FontEx propery.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.
' Create a new Dart.PowerTCP.Emulation.FontDialog class
Dim fDialog As New Dart.PowerTCP.Emulation.FontDialog()

' Show the dialog.
If fDialog.ShowDialog() = DialogResult.OK Then
   ' Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font
End If
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a new Dart.PowerTCP.Emulation.FontDialog class
Dart.PowerTCP.Emulation.FontDialog fDialog = new Dart.PowerTCP.Emulation.FontDialog();

// Show the dialog.
if(fDialog.ShowDialog() == DialogResult.OK)
{
   // Set the FontEx property (NOT the Font property which is deprecated).
   vt1.FontEx = fDialog.Font;
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.ForeColor Property

Gets or sets the foreground color for the control.

[Visual Basic]
Overrides Public Property ForeColor As Color
[C#]
public override System.Drawing.Color ForeColor {get; set;}

Property Value

A System.Drawing.Color value.

Remarks

This property defaults to Color.WindowText.

Example

[Visual Basic, C#] The following example demonstrates setting many of the simple properties to non-default values.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = False

' Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = False

' Set so lines do not wrap if they are too long.
vt1.AutoWrap = True

' Set backcolor to Red
vt1.BackColor = Color.Red

' Disable bell
vt1.Bell = False

' Set Blink Intensity to 40
vt1.BlinkIntensity = 40

' Set bold text color to Blue
vt1.BoldColor = Color.Blue

' Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application

' Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = New System.Drawing.Point(5, 5)

' Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline

' Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow

' "Swap" the foreground and background colors.
vt1.Inverse = True

' Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application

' Echo any typed keys to the display.
vt1.LocalEcho = True

' Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British

' Set Normal Intensity to 80
vt1.NormalIntensity = 80

' Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = New System.Drawing.Size(70, 20)

' Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump

' Change the size of the control to 250 X 100
vt1.Size = New System.Drawing.Size(250, 100)

' Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30"

' Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = False
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = false;

// Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = false;

// Set so lines do not wrap if they are too long.
vt1.AutoWrap = true;

// Set backcolor to Red
vt1.BackColor = Color.Red;

// Disable bell
vt1.Bell = false;

// Set Blink Intensity to 40
vt1.BlinkIntensity = 40;

// Set bold text color to Blue
vt1.BoldColor = Color.Blue;

// Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application;

// Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = new System.Drawing.Point(5, 5);

// Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline;

// Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow;

// "Swap" the foreground and background colors.
vt1.Inverse = true;

// Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application;

// Echo any typed keys to the display.
vt1.LocalEcho = true;

// Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British;

// Set Normal Intensity to 80
vt1.NormalIntensity = 80;

// Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = new System.Drawing.Size(70, 20);

// Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump;

// Change the size of the control to 250 X 100
vt1.Size = new System.Drawing.Size(250, 100);

// Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30";

// Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = false;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.Inverse Property

Gets or sets a value that determines whether the foreground and background colors are switched.

[Visual Basic]
Public Property Inverse As Boolean
[C#]
public bool Inverse {get; set;}

Property Value

true if the foreground and background colors should be switched; false otherwise. The default value is false.

Remarks

The Vt.ForeColor property sets the foreground color, and the Vt.BackColor property sets the background color.

If data is received from the host which causes this property to change, the Vt.InverseChanged event is raised.

Example

[Visual Basic, C#] The following example demonstrates setting many of the simple properties to non-default values.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = False

' Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = False

' Set so lines do not wrap if they are too long.
vt1.AutoWrap = True

' Set backcolor to Red
vt1.BackColor = Color.Red

' Disable bell
vt1.Bell = False

' Set Blink Intensity to 40
vt1.BlinkIntensity = 40

' Set bold text color to Blue
vt1.BoldColor = Color.Blue

' Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application

' Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = New System.Drawing.Point(5, 5)

' Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline

' Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow

' "Swap" the foreground and background colors.
vt1.Inverse = True

' Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application

' Echo any typed keys to the display.
vt1.LocalEcho = True

' Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British

' Set Normal Intensity to 80
vt1.NormalIntensity = 80

' Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = New System.Drawing.Size(70, 20)

' Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump

' Change the size of the control to 250 X 100
vt1.Size = New System.Drawing.Size(250, 100)

' Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30"

' Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = False
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = false;

// Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = false;

// Set so lines do not wrap if they are too long.
vt1.AutoWrap = true;

// Set backcolor to Red
vt1.BackColor = Color.Red;

// Disable bell
vt1.Bell = false;

// Set Blink Intensity to 40
vt1.BlinkIntensity = 40;

// Set bold text color to Blue
vt1.BoldColor = Color.Blue;

// Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application;

// Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = new System.Drawing.Point(5, 5);

// Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline;

// Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow;

// "Swap" the foreground and background colors.
vt1.Inverse = true;

// Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application;

// Echo any typed keys to the display.
vt1.LocalEcho = true;

// Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British;

// Set Normal Intensity to 80
vt1.NormalIntensity = 80;

// Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = new System.Drawing.Size(70, 20);

// Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump;

// Change the size of the control to 250 X 100
vt1.Size = new System.Drawing.Size(250, 100);

// Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30";

// Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = false;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.KeyPad Property

Gets or sets a value that determines whether the keypad sends ASCII characters or escape sequences.

[Visual Basic]
Public Property KeyPad As Keypad
[C#]
public Keypad KeyPad {get; set;}

Property Value

A KeyPad value. The default value is KeyPad.Numeric.

Remarks

ASCII character codes correspond to the numeric characters on the keys. Escape sequences are used by some applications.

If data is received from the host which causes this property to change, the Vt.KeyPadChanged event is raised.

Example

[Visual Basic, C#] The following example demonstrates setting many of the simple properties to non-default values.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = False

' Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = False

' Set so lines do not wrap if they are too long.
vt1.AutoWrap = True

' Set backcolor to Red
vt1.BackColor = Color.Red

' Disable bell
vt1.Bell = False

' Set Blink Intensity to 40
vt1.BlinkIntensity = 40

' Set bold text color to Blue
vt1.BoldColor = Color.Blue

' Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application

' Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = New System.Drawing.Point(5, 5)

' Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline

' Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow

' "Swap" the foreground and background colors.
vt1.Inverse = True

' Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application

' Echo any typed keys to the display.
vt1.LocalEcho = True

' Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British

' Set Normal Intensity to 80
vt1.NormalIntensity = 80

' Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = New System.Drawing.Size(70, 20)

' Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump

' Change the size of the control to 250 X 100
vt1.Size = New System.Drawing.Size(250, 100)

' Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30"

' Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = False
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = false;

// Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = false;

// Set so lines do not wrap if they are too long.
vt1.AutoWrap = true;

// Set backcolor to Red
vt1.BackColor = Color.Red;

// Disable bell
vt1.Bell = false;

// Set Blink Intensity to 40
vt1.BlinkIntensity = 40;

// Set bold text color to Blue
vt1.BoldColor = Color.Blue;

// Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application;

// Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = new System.Drawing.Point(5, 5);

// Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline;

// Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow;

// "Swap" the foreground and background colors.
vt1.Inverse = true;

// Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application;

// Echo any typed keys to the display.
vt1.LocalEcho = true;

// Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British;

// Set Normal Intensity to 80
vt1.NormalIntensity = 80;

// Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = new System.Drawing.Size(70, 20);

// Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump;

// Change the size of the control to 250 X 100
vt1.Size = new System.Drawing.Size(250, 100);

// Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30";

// Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = false;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.LocalEcho Property

Gets or sets a value which controls whether or not key presses are displayed on the Vt window.

[Visual Basic]
Public Property LocalEcho As Boolean
[C#]
public bool LocalEcho {get; set;}

Property Value

true if key presses should be displayed on the Vt window; false otherwise. The default value is false.

Remarks

Often, when communicating with remote hosts, the remote host will echo sent characters back to the user. If you are using the Vt control with LocalEcho set to true, this will result in a "doubling" of characters (i.e., typing "a" will actually display "aa" on the Vt window). If this is the case change LocalEcho to false and only one character will be displayed (the "echoed" one received from the remote host). If the remote host does not echo sent characters back, you may wish to set this property to true so the character is displayed when the key is pressed.

If data is received from the host which causes this property to change, the Vt.LocalEchoChanged event is raised.

Example

[Visual Basic, C#] The following example demonstrates setting many of the simple properties to non-default values.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = False

' Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = False

' Set so lines do not wrap if they are too long.
vt1.AutoWrap = True

' Set backcolor to Red
vt1.BackColor = Color.Red

' Disable bell
vt1.Bell = False

' Set Blink Intensity to 40
vt1.BlinkIntensity = 40

' Set bold text color to Blue
vt1.BoldColor = Color.Blue

' Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application

' Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = New System.Drawing.Point(5, 5)

' Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline

' Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow

' "Swap" the foreground and background colors.
vt1.Inverse = True

' Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application

' Echo any typed keys to the display.
vt1.LocalEcho = True

' Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British

' Set Normal Intensity to 80
vt1.NormalIntensity = 80

' Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = New System.Drawing.Size(70, 20)

' Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump

' Change the size of the control to 250 X 100
vt1.Size = New System.Drawing.Size(250, 100)

' Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30"

' Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = False
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = false;

// Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = false;

// Set so lines do not wrap if they are too long.
vt1.AutoWrap = true;

// Set backcolor to Red
vt1.BackColor = Color.Red;

// Disable bell
vt1.Bell = false;

// Set Blink Intensity to 40
vt1.BlinkIntensity = 40;

// Set bold text color to Blue
vt1.BoldColor = Color.Blue;

// Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application;

// Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = new System.Drawing.Point(5, 5);

// Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline;

// Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow;

// "Swap" the foreground and background colors.
vt1.Inverse = true;

// Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application;

// Echo any typed keys to the display.
vt1.LocalEcho = true;

// Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British;

// Set Normal Intensity to 80
vt1.NormalIntensity = 80;

// Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = new System.Drawing.Size(70, 20);

// Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump;

// Change the size of the control to 250 X 100
vt1.Size = new System.Drawing.Size(250, 100);

// Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30";

// Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = false;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.Margin Property

Gets or sets a Size object which determines the amount of "buffer" space around the Vt content on the window.

[Visual Basic]
Public Property Margin As Size
[C#]
public System.Drawing.Size Margin {get; set;}

Property Value

A System.Drawing.Size object.

Remarks

The default values are Size.Width = 4 and Size.Height = 4.

Example

[Visual Basic, C#] The following example demonstrates resizing the form (parent container) of the Vt control based on the size of the font. This is extremely useful for implementations that use some sort of docking type for the Vt control (i.e. Vt.Dock != DockStyle.None). If your code not using docking, you can simply use the Vt.Resize method to resize the control.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

Private Sub DoResize()
   ' Resize form based on size of font
   ' Height = (Num Rows * Row Height) + Margin Height + (Form Height - VT Height)
   ' Width = (Num Cols * Col Width) + Margin Width + Scrollbar Width + (Form Width - VT Width)
   me.Height = (vt1.ScreenSize.Height * vt1.CharacterSize.Height) + vt1.Margin.Height + (this.Height - vt1.Height)
   me.Width = (vt1.ScreenSize.Width * vt1.CharacterSize.Width) + vt1.Margin.Width + SystemInformation.VerticalScrollBarWidth + (this.Width - vt1.Width)
Ens Sub
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

private void DoResize()
{
   //Resize form based on size of font
   //Height = (Num Rows * Row Height) + Margin Height + (Form Height - VT Height)
   //Width = (Num Cols * Col Width) + Margin Width + Scrollbar Width + (Form Width - VT Width)
   this.Height = (vt1.ScreenSize.Height * vt1.CharacterSize.Height) + vt1.Margin.Height + (this.Height - vt1.Height);
   this.Width = (vt1.ScreenSize.Width * vt1.CharacterSize.Width) + vt1.Margin.Width + SystemInformation.VerticalScrollBarWidth + (this.Width - vt1.Width);
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.NationalCharSet Property

Gets or sets the national character set for use in VT220 7-bit or VT320 7-bit emulation modes to display special characters that normally require 8-bit emulation mode.

[Visual Basic]
Public Property NationalCharSet As NationalCharSet
[C#]
public NationalCharSet NationalCharSet {get; set;}

Property Value

A NationalCharSet value.

Remarks

The default value is NationalCharSet.Ascii.

Example

[Visual Basic, C#] The following example demonstrates setting many of the simple properties to non-default values.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = False

' Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = False

' Set so lines do not wrap if they are too long.
vt1.AutoWrap = True

' Set backcolor to Red
vt1.BackColor = Color.Red

' Disable bell
vt1.Bell = False

' Set Blink Intensity to 40
vt1.BlinkIntensity = 40

' Set bold text color to Blue
vt1.BoldColor = Color.Blue

' Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application

' Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = New System.Drawing.Point(5, 5)

' Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline

' Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow

' "Swap" the foreground and background colors.
vt1.Inverse = True

' Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application

' Echo any typed keys to the display.
vt1.LocalEcho = True

' Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British

' Set Normal Intensity to 80
vt1.NormalIntensity = 80

' Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = New System.Drawing.Size(70, 20)

' Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump

' Change the size of the control to 250 X 100
vt1.Size = New System.Drawing.Size(250, 100)

' Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30"

' Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = False
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = false;

// Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = false;

// Set so lines do not wrap if they are too long.
vt1.AutoWrap = true;

// Set backcolor to Red
vt1.BackColor = Color.Red;

// Disable bell
vt1.Bell = false;

// Set Blink Intensity to 40
vt1.BlinkIntensity = 40;

// Set bold text color to Blue
vt1.BoldColor = Color.Blue;

// Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application;

// Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = new System.Drawing.Point(5, 5);

// Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline;

// Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow;

// "Swap" the foreground and background colors.
vt1.Inverse = true;

// Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application;

// Echo any typed keys to the display.
vt1.LocalEcho = true;

// Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British;

// Set Normal Intensity to 80
vt1.NormalIntensity = 80;

// Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = new System.Drawing.Size(70, 20);

// Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump;

// Change the size of the control to 250 X 100
vt1.Size = new System.Drawing.Size(250, 100);

// Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30";

// Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = false;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.NewLine Property

Gets or sets the end-of-line character sequence to use.

[Visual Basic]
Public Property NewLine As NewLine
[C#]
public NewLine NewLine {get; set;}

Property Value

A NewLine value. The default value is NewLine.Cr.

Remarks

This property determines if either a single CR or CR/LF combination is used as a line terminator.

If data is received from the host which causes this property to change, the Vt.NewLineChanged event is raised.

Example

[Visual Basic, C#] The following example demonstrates simple use of the AutoPrint feature.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.
' Clear the Vt display
vt1.Clear()

' Change line terminator
vt1.NewLine = NewLine.CrLf

' Turn on auto print
vt1.Print = PrintType.Auto

' Simulate data ariving from host. Data should print
' with each CRLF received.
vt1.Write("line 1" & vbCrLF)
vt1.Write("line 2" & vbCrLf)
vt1.Write("line 3" & vbCrLf)

' Terminate print job
vt1.Print = PrintType.Off
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Clear the Vt display
vt1.Clear();

// Change line terminator
vt1.NewLine = NewLine.CrLf;

// Turn on auto print
vt1.Print = PrintType.Auto;

// Simulate data ariving from host. Data should print
// with each CRLF received.
vt1.Write("line 1\r\n");
vt1.Write("line 2\r\n");
vt1.Write("line 3\r\n");

// Terminate print job
vt1.Print = PrintType.Off;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

[Visual Basic, C#] The following example demonstrates

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.NormalIntensity Property

Gets or sets the "brightness" of normal text.

[Visual Basic]
Public Property NormalIntensity As Integer
[C#]
public int NormalIntensity {get; set;}

Property Value

An integer specifying the "brightness" level. The default value is 100.

Remarks

The valid range is 0 to 100.

Example

[Visual Basic, C#] The following example demonstrates setting many of the simple properties to non-default values.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = False

' Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = False

' Set so lines do not wrap if they are too long.
vt1.AutoWrap = True

' Set backcolor to Red
vt1.BackColor = Color.Red

' Disable bell
vt1.Bell = False

' Set Blink Intensity to 40
vt1.BlinkIntensity = 40

' Set bold text color to Blue
vt1.BoldColor = Color.Blue

' Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application

' Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = New System.Drawing.Point(5, 5)

' Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline

' Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow

' "Swap" the foreground and background colors.
vt1.Inverse = True

' Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application

' Echo any typed keys to the display.
vt1.LocalEcho = True

' Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British

' Set Normal Intensity to 80
vt1.NormalIntensity = 80

' Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = New System.Drawing.Size(70, 20)

' Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump

' Change the size of the control to 250 X 100
vt1.Size = New System.Drawing.Size(250, 100)

' Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30"

' Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = False
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = false;

// Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = false;

// Set so lines do not wrap if they are too long.
vt1.AutoWrap = true;

// Set backcolor to Red
vt1.BackColor = Color.Red;

// Disable bell
vt1.Bell = false;

// Set Blink Intensity to 40
vt1.BlinkIntensity = 40;

// Set bold text color to Blue
vt1.BoldColor = Color.Blue;

// Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application;

// Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = new System.Drawing.Point(5, 5);

// Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline;

// Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow;

// "Swap" the foreground and background colors.
vt1.Inverse = true;

// Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application;

// Echo any typed keys to the display.
vt1.LocalEcho = true;

// Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British;

// Set Normal Intensity to 80
vt1.NormalIntensity = 80;

// Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = new System.Drawing.Size(70, 20);

// Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump;

// Change the size of the control to 250 X 100
vt1.Size = new System.Drawing.Size(250, 100);

// Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30";

// Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = false;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.Print Property

Gets or sets a PrintType specifying how printing should occur.

[Visual Basic]
Public Property Print As PrintType
[C#]
public PrintType Print {get; set;}

Property Value

A PrintType value. The default value is PrintType.Off.

Remarks

When using the default value of PrintType.Off, printing occurs by explicitly calling the Vt print functions (PrintScreen(), PrintSelectedText(), and PrintCursorLint()). Set this property to PrintType.Auto or PrintType.Controller to print data automatically as it is received.

If data is received from the host which causes this property to change, the Vt.PrintChanged event is raised.

Example

[Visual Basic, C#] The following example demonstrates simple use of the AutoPrint feature.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.
' Clear the Vt display
vt1.Clear()

' Change line terminator
vt1.NewLine = NewLine.CrLf

' Turn on auto print
vt1.Print = PrintType.Auto

' Simulate data ariving from host. Data should print
' with each CRLF received.
vt1.Write("line 1" & vbCrLF)
vt1.Write("line 2" & vbCrLf)
vt1.Write("line 3" & vbCrLf)

' Terminate print job
vt1.Print = PrintType.Off
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Clear the Vt display
vt1.Clear();

// Change line terminator
vt1.NewLine = NewLine.CrLf;

// Turn on auto print
vt1.Print = PrintType.Auto;

// Simulate data ariving from host. Data should print
// with each CRLF received.
vt1.Write("line 1\r\n");
vt1.Write("line 2\r\n");
vt1.Write("line 3\r\n");

// Terminate print job
vt1.Print = PrintType.Off;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

[Visual Basic, C#] The following example demonstrates

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.PrintPassthrough Property

Gets or sets a value that determines if printing bypasses the normal printer drivers and prints directly to the printer port.

[Visual Basic]
Public Property PrintPassthrough As Boolean
[C#]
public bool PrintPassthrough {get; set;}

Property Value

true if passthrough printing is used; false otherwise. The default value is false.

Remarks

Intended for use with postscript printers. The data is not interpreted, but sent directly to the printer.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.ScreenSize Property

Gets or sets the screen size (number of columns and rows) used by the Vt window.

[Visual Basic]
Public Property ScreenSize As Size
[C#]
public System.Drawing.Size ScreenSize {get; set;}

Property Value

A System.Drawing.Size object.

Remarks

This property is useful both for resizing the Vt window (for example, when font size changes) or to calculate characters for some operation. For example, if you wished to select all of the characters in the scroll-back buffer, you could calculate the length of the characters in the scroll-back buffer by multiplying Vt.BufferRows (the number of rows in the scroll-back buffer) by Vt.ScreenSize.Width (the number of columns per row). Using this example, it is also necessary to add 2 to Vt.ScreenSize.Width before multiplying to account for an extra CrLf.

If data is received from the host which causes this property to change, the Vt.ScreenSizeChanged event is raised.

Example

[Visual Basic, C#] The following example demonstrates selecting the text on the display window. The display window is calculated using BufferRows and ScreenSize. Note, this does the exact same thing as PrintScreen, and is just shown to demonstrate how to calculate where text is on the Vt display.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Select the display window.
vt1.SelectionStart = vt1.BufferRows * (vt1.ScreenSize.Width + 2)
vt1.SelectionLength = vt1.ScreenSize.Height * (vt1.ScreenSize.Width + 2)

' Display the selected text
MessageBox.Show("Selected Text = " + vt1.SelectedText)

' Print the selected text
vt1.PrintSelectedText()

' ...

' As an alternative to all of the above code, you can simply use...
vt1.PrintScreen()
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Select the display window.
vt1.SelectionStart = vt1.BufferRows * (vt1.ScreenSize.Width + 2);
vt1.SelectionLength = vt1.ScreenSize.Height * (vt1.ScreenSize.Width + 2);

// Display the selected text
MessageBox.Show("Selected Text = " + vt1.SelectedText);

// Print the selected text
vt1.PrintSelectedText();

// ...

// As an alternative to all of the above code, you can simply use...
vt1.PrintScreen();

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.ScrollType Property

Gets or sets a value that determines whether to use jump scrolling or smooth scrolling in the display screen.

[Visual Basic]
Public Property ScrollType As Scroll
[C#]
public Scroll ScrollType {get; set;}

Property Value

A Scroll value. The default value is Scroll.Smooth.

Remarks

Jump scrolling displays new lines as fast as they are received causing lines to jump when data is received at a high rate. Smooth scrolling limits the rate at which new lines appear on the screen resulting in smother data display, even when data is received at a high rate.

If data is received from the host which causes this property to change, the Vt.ScrollTypeChanged event is raised.

Example

[Visual Basic, C#] The following example demonstrates setting many of the simple properties to non-default values.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = False

' Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = False

' Set so lines do not wrap if they are too long.
vt1.AutoWrap = True

' Set backcolor to Red
vt1.BackColor = Color.Red

' Disable bell
vt1.Bell = False

' Set Blink Intensity to 40
vt1.BlinkIntensity = 40

' Set bold text color to Blue
vt1.BoldColor = Color.Blue

' Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application

' Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = New System.Drawing.Point(5, 5)

' Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline

' Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow

' "Swap" the foreground and background colors.
vt1.Inverse = True

' Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application

' Echo any typed keys to the display.
vt1.LocalEcho = True

' Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British

' Set Normal Intensity to 80
vt1.NormalIntensity = 80

' Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = New System.Drawing.Size(70, 20)

' Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump

' Change the size of the control to 250 X 100
vt1.Size = New System.Drawing.Size(250, 100)

' Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30"

' Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = False
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = false;

// Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = false;

// Set so lines do not wrap if they are too long.
vt1.AutoWrap = true;

// Set backcolor to Red
vt1.BackColor = Color.Red;

// Disable bell
vt1.Bell = false;

// Set Blink Intensity to 40
vt1.BlinkIntensity = 40;

// Set bold text color to Blue
vt1.BoldColor = Color.Blue;

// Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application;

// Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = new System.Drawing.Point(5, 5);

// Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline;

// Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow;

// "Swap" the foreground and background colors.
vt1.Inverse = true;

// Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application;

// Echo any typed keys to the display.
vt1.LocalEcho = true;

// Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British;

// Set Normal Intensity to 80
vt1.NormalIntensity = 80;

// Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = new System.Drawing.Size(70, 20);

// Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump;

// Change the size of the control to 250 X 100
vt1.Size = new System.Drawing.Size(250, 100);

// Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30";

// Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = false;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.SelectedText Property

Gets the currently selected text.

[Visual Basic]
Public ReadOnly Property SelectedText As String
[C#]
public string SelectedText {get;}

Property Value

A string containing the text on the Vt window that is selected.

Remarks

If no text is selected, this property will return an empty string.

Example

[Visual Basic, C#] The following example demonstrates selecting the text on the display window. The display window is calculated using BufferRows and ScreenSize. Note, this does the exact same thing as PrintScreen, and is just shown to demonstrate how to calculate where text is on the Vt display.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Select the display window.
vt1.SelectionStart = vt1.BufferRows * (vt1.ScreenSize.Width + 2)
vt1.SelectionLength = vt1.ScreenSize.Height * (vt1.ScreenSize.Width + 2)

' Display the selected text
MessageBox.Show("Selected Text = " + vt1.SelectedText)

' Print the selected text
vt1.PrintSelectedText()

' ...

' As an alternative to all of the above code, you can simply use...
vt1.PrintScreen()
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Select the display window.
vt1.SelectionStart = vt1.BufferRows * (vt1.ScreenSize.Width + 2);
vt1.SelectionLength = vt1.ScreenSize.Height * (vt1.ScreenSize.Width + 2);

// Display the selected text
MessageBox.Show("Selected Text = " + vt1.SelectedText);

// Print the selected text
vt1.PrintSelectedText();

// ...

// As an alternative to all of the above code, you can simply use...
vt1.PrintScreen();

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.SelectionLength Property

Gets or sets the length of the number of characters selected.

[Visual Basic]
Public Property SelectionLength As Integer
[C#]
public int SelectionLength {get; set;}

Property Value

An integer specifying how many characters are selected. The default value is 0.

Remarks

This property includes 2 additional characters for the CR/LF at the end of each line. When set to 0, no text is selected.

Example

[Visual Basic, C#] The following example demonstrates selecting the text on the display window. The display window is calculated using BufferRows and ScreenSize. Note, this does the exact same thing as PrintScreen, and is just shown to demonstrate how to calculate where text is on the Vt display.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Select the display window.
vt1.SelectionStart = vt1.BufferRows * (vt1.ScreenSize.Width + 2)
vt1.SelectionLength = vt1.ScreenSize.Height * (vt1.ScreenSize.Width + 2)

' Display the selected text
MessageBox.Show("Selected Text = " + vt1.SelectedText)

' Print the selected text
vt1.PrintSelectedText()

' ...

' As an alternative to all of the above code, you can simply use...
vt1.PrintScreen()
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Select the display window.
vt1.SelectionStart = vt1.BufferRows * (vt1.ScreenSize.Width + 2);
vt1.SelectionLength = vt1.ScreenSize.Height * (vt1.ScreenSize.Width + 2);

// Display the selected text
MessageBox.Show("Selected Text = " + vt1.SelectedText);

// Print the selected text
vt1.PrintSelectedText();

// ...

// As an alternative to all of the above code, you can simply use...
vt1.PrintScreen();

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.SelectionStart Property

Gets or sets the starting index of the characters currently selected.

[Visual Basic]
Public Property SelectionStart As Integer
[C#]
public int SelectionStart {get; set;}

Property Value

An integer specfiying the first character to select. The default value is 0.

Remarks

Note that this property includes the scroll-back buffer, so if Vt.BufferRows is 72, and Vt.SelectionStart is 0, the first selected character is the first character in the buffer, not the first visible character on the Vt display.

Example

[Visual Basic, C#] The following example demonstrates selecting the text on the display window. The display window is calculated using BufferRows and ScreenSize. Note, this does the exact same thing as PrintScreen, and is just shown to demonstrate how to calculate where text is on the Vt display.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Select the display window.
vt1.SelectionStart = vt1.BufferRows * (vt1.ScreenSize.Width + 2)
vt1.SelectionLength = vt1.ScreenSize.Height * (vt1.ScreenSize.Width + 2)

' Display the selected text
MessageBox.Show("Selected Text = " + vt1.SelectedText)

' Print the selected text
vt1.PrintSelectedText()

' ...

' As an alternative to all of the above code, you can simply use...
vt1.PrintScreen()
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Select the display window.
vt1.SelectionStart = vt1.BufferRows * (vt1.ScreenSize.Width + 2);
vt1.SelectionLength = vt1.ScreenSize.Height * (vt1.ScreenSize.Width + 2);

// Display the selected text
MessageBox.Show("Selected Text = " + vt1.SelectedText);

// Print the selected text
vt1.PrintSelectedText();

// ...

// As an alternative to all of the above code, you can simply use...
vt1.PrintScreen();

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.StatusLine Property

Gets or sets a value that indicates whether a 25th line is displayed as a status line when in VT320 7-bit or 8-bit mode.

[Visual Basic]
Public Property StatusLine As String
[C#]
public string StatusLine {get; set;}

Property Value

A string containing the status text to display on the status line. The default value is an empty string, indicating the status line is not displayed.

Remarks

Some applications use the status line for status information. The TermType property must be vt320_7 or vt320_8 for the status line to appear.

If you wish to display the status line, set this property to the string you wish to display. If you do not wish to display the status line, set this property to an empty string. If you wish to display the status line but no text, set this property to a space.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.Tabs Property

Gets or sets a list of comma-delimited tab positions.

[Visual Basic]
Public Property Tabs As String
[C#]
public string Tabs {get; set;}

Property Value

A string containing the comma-delimited tab positions. The default value is "8,16,24,32,40,48,56,64,72,80,88,96,104,112,120,128".

Remarks

If data is received from the host which causes this property to change, the Vt.TabsChanged event is raised.

Example

[Visual Basic, C#] The following example demonstrates setting many of the simple properties to non-default values.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = False

' Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = False

' Set so lines do not wrap if they are too long.
vt1.AutoWrap = True

' Set backcolor to Red
vt1.BackColor = Color.Red

' Disable bell
vt1.Bell = False

' Set Blink Intensity to 40
vt1.BlinkIntensity = 40

' Set bold text color to Blue
vt1.BoldColor = Color.Blue

' Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application

' Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = New System.Drawing.Point(5, 5)

' Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline

' Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow

' "Swap" the foreground and background colors.
vt1.Inverse = True

' Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application

' Echo any typed keys to the display.
vt1.LocalEcho = True

' Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British

' Set Normal Intensity to 80
vt1.NormalIntensity = 80

' Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = New System.Drawing.Size(70, 20)

' Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump

' Change the size of the control to 250 X 100
vt1.Size = New System.Drawing.Size(250, 100)

' Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30"

' Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = False
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = false;

// Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = false;

// Set so lines do not wrap if they are too long.
vt1.AutoWrap = true;

// Set backcolor to Red
vt1.BackColor = Color.Red;

// Disable bell
vt1.Bell = false;

// Set Blink Intensity to 40
vt1.BlinkIntensity = 40;

// Set bold text color to Blue
vt1.BoldColor = Color.Blue;

// Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application;

// Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = new System.Drawing.Point(5, 5);

// Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline;

// Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow;

// "Swap" the foreground and background colors.
vt1.Inverse = true;

// Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application;

// Echo any typed keys to the display.
vt1.LocalEcho = true;

// Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British;

// Set Normal Intensity to 80
vt1.NormalIntensity = 80;

// Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = new System.Drawing.Size(70, 20);

// Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump;

// Change the size of the control to 250 X 100
vt1.Size = new System.Drawing.Size(250, 100);

// Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30";

// Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = false;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.Telnet Property

Gets the internal Telnet control to use for online communications.

[Visual Basic]
Public ReadOnly Property Telnet As Telnet
[C#]
public Telnet Telnet {get;}

Property Value

A Dart.PowerTCP.Emulation.Telnet instance used for online communications.

Remarks

Although the Vt control was designed to work with data from any source (file, memory, remote host, etc) the most common usage is to use it to display data received from a remote host. To make this easier, a Telnet control, which can be used to communicate with remote hosts, is included and exposed as the Vt.Telnet property.

To use the Telnet control, simply call the Vt.Telnet.Connect method to connect to a remote host. Any data received from the remote host is automatically displayed in the Vt window. Any key presses on the Vt window are automatically sent to the remote host.

If you would like a finer level of control over the online communications, the Telnet control can also be used externally from the Vt control. See the included samples for a demonstration.

Example

[Visual Basic, C#] The following example demonstrates creating a simple VT application using the internal Telnet control. In addition, creating a diagnostic log using the Capture method is also demonstrated.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.
Dim f as System.IO.FileStream

Private Sub OpenTelnetConnection()
   ' Create a new filestream
   f = New System.IO.FileStream("C:\temp\log.txt", System.IO.FileMode.Create)

   ' Capture all data displayed on the Vt window
   vt1.Capture(f)

   ' Connect to a Telnet server
   vt1.Telnet.Connect("myserver")
End Sub

Private Void CloseTelnetConnection()
   ' Close the connection
   vt1.Telnet.Close()

   ' Close the filestream
   f.Close()
End Sub
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

System.IO.FileStream  f = null;

private void OpenTelnetConnection()
{
   // Create a new filestream
   f = new System.IO.FileStream("C:\\temp\\log.txt", System.IO.FileMode.Create);

   // Capture all data displayed on the Vt window
   vt1.Capture(f);

   // Connect to a Telnet server
   vt1.Telnet.Connect("myserver");
}

private void CloseTelnetConnection()
{
   // Close the connection
   vt1.Telnet.Close();

   // Close the filestream
   f.Close();
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.TerminalType Property

Gets or sets the terminal type to emulate.

[Visual Basic]
Public Property TerminalType As TerminalType
[C#]
public TerminalType TerminalType {get; set;}

Property Value

A TerminalType value. The default value is TerminalType.Vt370_7.

Remarks

Escape sequences are interpreted using the terminal type specified in this property.

If data is received from the host which causes this property to change, the Vt.TerminalTypeChanged event is raised.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.Text Property

DO NOT USE THE TEXT PROPERTY. USE THE WRITE METHOD TO ADD TEXT TO THE VT AND THE SCRAPETEXT METHOD TO GET TEXT FROM THE VT.

[Visual Basic]
Overrides Public Property Text As String
[C#]
public override string Text {get; set;}

Property Value

This property always throws a compiler exception.

Remarks

This property was automatically inherited as part of System.Windows.Forms.Control, but obsoleted. To add text to the Vt window, use the Vt.Write method. To get text from the Vt window, use the Vt.ScrapeText method.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.TextLength Property

Returns the length of the data in the Vt window.

[Visual Basic]
Public ReadOnly Property TextLength As Integer
[C#]
public int TextLength {get;}

Remarks

The length of the data is calculated using the following formula:

            vt.BufferRows + vt.ScreenSize.Height * (vt.ScreenSize.Width + 2)

Example

[Visual Basic, C#] The following example demonstrates simple text scraping.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Clear the display
vt1.Clear()

' Add some dummy data including escape sequences for formatting
vt1.Write(Chr(27) + "[1mTest " + Chr(27) + "[0mdata" + Chr(27) + "[7m blah " + Chr(27) + "[0m")

' Scrape the text
Dim s As String = vt1.ScrapeText(0, vt1.TextLength)

' Display the text, the escape sequences should be gone,
' leaving "Test data blah"
textBox1.Text = s.Trim()
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Clear the display
vt1.Clear();

// Add some dummy data including escape sequences for formatting
vt1.Write("\x1b[1mTest \x1b[0mdata\x1b[7m blah \x1b[0m");

// Scrape the text
string s = vt1.ScrapeText(0, vt1.TextLength);

// Display the text, the escape sequences should be gone,
// leaving "Test data blah"
textBox1.Text = s.Trim();

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.UseDefaultPrinter Property

Gets or sets a value which indicates whether the system default printer or a user-selected printer is used.

[Visual Basic]
Public Property UseDefaultPrinter As Boolean
[C#]
public bool UseDefaultPrinter {get; set;}

Property Value

true if the default system printer should automatically be used; false otherwise. The default value is true.

Remarks

If this value is set to false a system "Choose Printer" dialog box is presented to the user whenever printing needs to occur.

Example

[Visual Basic, C#] The following example demonstrates setting many of the simple properties to non-default values.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = False

' Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = False

' Set so lines do not wrap if they are too long.
vt1.AutoWrap = True

' Set backcolor to Red
vt1.BackColor = Color.Red

' Disable bell
vt1.Bell = False

' Set Blink Intensity to 40
vt1.BlinkIntensity = 40

' Set bold text color to Blue
vt1.BoldColor = Color.Blue

' Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application

' Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = New System.Drawing.Point(5, 5)

' Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline

' Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow

' "Swap" the foreground and background colors.
vt1.Inverse = True

' Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application

' Echo any typed keys to the display.
vt1.LocalEcho = True

' Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British

' Set Normal Intensity to 80
vt1.NormalIntensity = 80

' Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = New System.Drawing.Size(70, 20)

' Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump

' Change the size of the control to 250 X 100
vt1.Size = New System.Drawing.Size(250, 100)

' Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30"

' Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = False
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Set so a "tab" keypress shifts focus to the next control.
vt1.AcceptTabs = false;

// Set so only one keystroke is generated if the key is held down.
vt1.AutoRepeat = false;

// Set so lines do not wrap if they are too long.
vt1.AutoWrap = true;

// Set backcolor to Red
vt1.BackColor = Color.Red;

// Disable bell
vt1.Bell = false;

// Set Blink Intensity to 40
vt1.BlinkIntensity = 40;

// Set bold text color to Blue
vt1.BoldColor = Color.Blue;

// Set so cursor keys generate application control sequences
vt1.CursorKeys = CursorKeys.Application;

// Set cursor position to the 5th row of the 5th column of the visible display.
vt1.CursorPosition = new System.Drawing.Point(5, 5);

// Set cursor style to underline.
vt1.CursorStyle = CursorStyle.Underline;

// Set foreground color to Yellow.
vt1.ForeColor = Color.Yellow;

// "Swap" the foreground and background colors.
vt1.Inverse = true;

// Change so keypad keys generate application specific values
vt1.KeyPad = Keypad.Application;

// Echo any typed keys to the display.
vt1.LocalEcho = true;

// Change the national character set to British.
vt1.NationalCharSet = NationalCharSet.British;

// Set Normal Intensity to 80
vt1.NormalIntensity = 80;

// Change the amount of columns to 70 and the rows to 20
vt1.ScreenSize = new System.Drawing.Size(70, 20);

// Set the scroll type to Jump
vt1.ScrollType = Scroll.Jump;

// Change the size of the control to 250 X 100
vt1.Size = new System.Drawing.Size(250, 100);

// Set the tabs to be on the 10th, 20th, and 30th columns.
vt1.Tabs = "10,20,30";

// Let the user choose the printer when printing is required
vt1.UseDefaultPrinter = false;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt Methods

The methods of the Vt class are listed below. For a complete list of Vt class members, see the Vt Members topic.

Public Instance Methods

BeginInvoke (inherited from Control) | Overloaded. Executes the specified delegate asynchronously with the specified arguments, on the thread that the control's underlying handle was created on.
BringToFront (inherited from Control) | Brings the control to the front of the z-order.
Capture | Save subsequent display data to the provided stream.
Clear | Clears the scrollback buffer and all rows in the display screen.
Contains (inherited from Control) | Retrieves a value indicating whether the specified control is a child of the control.
CreateControl (inherited from Control) | Forces the creation of the control, including the creation of the handle and any child controls.
CreateGraphics (inherited from Control) | Creates the Graphics object for the control.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from Component) | Releases all resources used by the Component.
DoDragDrop (inherited from Control) | Begins a drag-and-drop operation.
EndInvoke (inherited from Control) | Retrieves the return value of the asynchronous operation represented by the IAsyncResult object passed.
EnsureVisible | Scrolls the screen to ensure the specified row is visible.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
FindForm (inherited from Control) | Retrieves the form that the control is on.
Focus (inherited from Control) | Sets input focus to the control.
GetChildAtPoint (inherited from Control) | Retrieves the child control that is located at the specified coordinates.
GetContainerControl (inherited from Control) | Returns the next ContainerControl up the control's chain of parent controls.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetNextControl (inherited from Control) | Retrieves the next control forward or back in the tab order of child controls.
GetType (inherited from Object) | Gets the Type of the current instance.
Hide (inherited from Control) | Conceals the control from the user.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Invalidate (inherited from Control) | Overloaded. Invalidates the specified region of the control (adds it to the control's update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the control.
Invoke (inherited from Control) | Overloaded. Executes the specified delegate, on the thread that owns the control's underlying window handle, with the specified list of arguments.
PerformLayout (inherited from Control) | Overloaded. Forces the control to apply layout logic to all its child controls.
PointToClient (inherited from Control) | Computes the location of the specified screen point into client coordinates.
PointToScreen (inherited from Control) | Computes the location of the specified client point into screen coordinates.
PreProcessMessage (inherited from Control) | Preprocesses input messages within the message loop before they are dispatched.
PrintCursorLine | Sends a copy of the line the cursor is currently on to the printer.
PrintScreen | Sends a copy of the display screen to the printer.
PrintSelectedText | Sends a copy of the currently selected text to the printer.
RectangleToClient (inherited from Control) | Computes the size and location of the specified screen rectangle in client coordinates.
RectangleToScreen (inherited from Control) | Computes the size and location of the specified client rectangle in screen coordinates.
Refresh | Refreshes the screen using current properties.
ResetBackColor (inherited from Control) | Resets the BackColor property to its default value.
ResetBindings (inherited from Control) | Resets the DataBindings property to its default value.
ResetCursor (inherited from Control) | Resets the Cursor property to its default value.
ResetFont (inherited from Control) | Resets the Fontproperty to its default value.
ResetForeColor (inherited from Control) | Resets the ForeColor property to its default value.
ResetImeMode (inherited from Control) | Resets the ImeMode property to its default value.
ResetRightToLeft (inherited from Control) | Resets the RightToLeft property to its default value.
ResetText (inherited from Control) | Resets the Text property to its default value.
Resize | Resizes the screen using current properties.
ResumeLayout (inherited from Control) | Overloaded. Resumes normal layout logic.
Scale (inherited from Control) | Overloaded. Scales the control and any child controls to the specified ratio.
ScrapeCells | Overloaded. Retrieves information about the cells in the specified range.
ScrapeHtml | Overloaded. Returns an HTML representation of the VT data.
ScrapeText | Overloaded. Retrieves text (minus escape characters) from the Vt display.
Select (inherited from Control) | Activates the control.
SelectNextControl (inherited from Control) | Activates the next control.
SendToBack (inherited from Control) | Sends the control to the back of the z-order.
SetBounds (inherited from Control) | Overloaded. Sets the bounds of the control to the specified location and size.
SetDefaultFont | Resets the font to its default value and applies the size change specified.
Show (inherited from Control) | Displays the control to the user.
SuspendLayout (inherited from Control) | Temporarily suspends the layout logic for the control.
ToString (inherited from Component) |
Update (inherited from Control) | Causes the control to redraw the invalidated regions within its client area.
Write | Overloaded. Displays the data contained within a byte array in the Vt window and interprets all escape sequences.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.Capture Method

Save subsequent display data to the provided stream.

[Visual Basic]
Public Sub Capture( _
ByVal destinationStream As Stream _
)
[C#]
new public void Capture(
Stream destinationStream
);

Parameters

destinationStream
The destination stream for the captured data.

Remarks

The Capture method can be used to easily create a log of all data displayed in the Vt window. This is especially useful when using the internal Telnet control to communicate with remote hosts.

Example

[Visual Basic, C#] The following example demonstrates creating a simple VT application using the internal Telnet control. In addition, creating a diagnostic log using the Capture method is also demonstrated.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.
Dim f as System.IO.FileStream

Private Sub OpenTelnetConnection()
   ' Create a new filestream
   f = New System.IO.FileStream("C:\temp\log.txt", System.IO.FileMode.Create)

   ' Capture all data displayed on the Vt window
   vt1.Capture(f)

   ' Connect to a Telnet server
   vt1.Telnet.Connect("myserver")
End Sub

Private Void CloseTelnetConnection()
   ' Close the connection
   vt1.Telnet.Close()

   ' Close the filestream
   f.Close()
End Sub
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

System.IO.FileStream  f = null;

private void OpenTelnetConnection()
{
   // Create a new filestream
   f = new System.IO.FileStream("C:\\temp\\log.txt", System.IO.FileMode.Create);

   // Capture all data displayed on the Vt window
   vt1.Capture(f);

   // Connect to a Telnet server
   vt1.Telnet.Connect("myserver");
}

private void CloseTelnetConnection()
{
   // Close the connection
   vt1.Telnet.Close();

   // Close the filestream
   f.Close();
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.Clear Method

Clears the scrollback buffer and all rows in the display screen.

[Visual Basic]
Public Sub Clear()
[C#]
public void Clear();

Remarks

The scrollback buffer and the display screen is filled with space characters.

Example

[Visual Basic, C#] The following example demonstrates simple use of the AutoPrint feature.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.
' Clear the Vt display
vt1.Clear()

' Change line terminator
vt1.NewLine = NewLine.CrLf

' Turn on auto print
vt1.Print = PrintType.Auto

' Simulate data ariving from host. Data should print
' with each CRLF received.
vt1.Write("line 1" & vbCrLF)
vt1.Write("line 2" & vbCrLf)
vt1.Write("line 3" & vbCrLf)

' Terminate print job
vt1.Print = PrintType.Off
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Clear the Vt display
vt1.Clear();

// Change line terminator
vt1.NewLine = NewLine.CrLf;

// Turn on auto print
vt1.Print = PrintType.Auto;

// Simulate data ariving from host. Data should print
// with each CRLF received.
vt1.Write("line 1\r\n");
vt1.Write("line 2\r\n");
vt1.Write("line 3\r\n");

// Terminate print job
vt1.Print = PrintType.Off;

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

[Visual Basic, C#] The following example demonstrates

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.EnsureVisible Method

Scrolls the screen to ensure the specified row is visible.

[Visual Basic]
Public Sub EnsureVisible( _
ByVal screenRow As Integer _
)
[C#]
public void EnsureVisible(
int screenRow
);

Parameters

screenRow
The row that remains visible.

Remarks

NOTE. Scroll-back buffer rows are not taked into account. Screen row is between 0 and (ScreenSize.Height - 1).

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.PrintCursorLine Method

Sends a copy of the line the cursor is currently on to the printer.

[Visual Basic]
Public Sub PrintCursorLine()
[C#]
public void PrintCursorLine();

Remarks

If the Vt.UseDefaultPrinter is true, data is sent to the default printer. If the Vt.UseDefaultPrinter property is false, a "Choose Printer" dialog is displayed to the user.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.PrintScreen Method

Sends a copy of the display screen to the printer.

[Visual Basic]
Public Sub PrintScreen()
[C#]
public void PrintScreen();

Remarks

If the Vt.UseDefaultPrinter is true, data is sent to the default printer. If the Vt.UseDefaultPrinter property is false, a "Choose Printer" dialog is displayed to the user.

Example

[Visual Basic, C#] The following example demonstrates selecting the text on the display window. The display window is calculated using BufferRows and ScreenSize. Note, this does the exact same thing as PrintScreen, and is just shown to demonstrate how to calculate where text is on the Vt display.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Select the display window.
vt1.SelectionStart = vt1.BufferRows * (vt1.ScreenSize.Width + 2)
vt1.SelectionLength = vt1.ScreenSize.Height * (vt1.ScreenSize.Width + 2)

' Display the selected text
MessageBox.Show("Selected Text = " + vt1.SelectedText)

' Print the selected text
vt1.PrintSelectedText()

' ...

' As an alternative to all of the above code, you can simply use...
vt1.PrintScreen()
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Select the display window.
vt1.SelectionStart = vt1.BufferRows * (vt1.ScreenSize.Width + 2);
vt1.SelectionLength = vt1.ScreenSize.Height * (vt1.ScreenSize.Width + 2);

// Display the selected text
MessageBox.Show("Selected Text = " + vt1.SelectedText);

// Print the selected text
vt1.PrintSelectedText();

// ...

// As an alternative to all of the above code, you can simply use...
vt1.PrintScreen();

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.PrintSelectedText Method

Sends a copy of the currently selected text to the printer.

[Visual Basic]
Public Sub PrintSelectedText()
[C#]
public void PrintSelectedText();

Remarks

If the Vt.UseDefaultPrinter is true, data is sent to the default printer. If the Vt.UseDefaultPrinter property is false, a "Choose Printer" dialog is displayed to the user.

Example

[Visual Basic, C#] The following example demonstrates selecting the text on the display window. The display window is calculated using BufferRows and ScreenSize. Note, this does the exact same thing as PrintScreen, and is just shown to demonstrate how to calculate where text is on the Vt display.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Select the display window.
vt1.SelectionStart = vt1.BufferRows * (vt1.ScreenSize.Width + 2)
vt1.SelectionLength = vt1.ScreenSize.Height * (vt1.ScreenSize.Width + 2)

' Display the selected text
MessageBox.Show("Selected Text = " + vt1.SelectedText)

' Print the selected text
vt1.PrintSelectedText()

' ...

' As an alternative to all of the above code, you can simply use...
vt1.PrintScreen()
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Select the display window.
vt1.SelectionStart = vt1.BufferRows * (vt1.ScreenSize.Width + 2);
vt1.SelectionLength = vt1.ScreenSize.Height * (vt1.ScreenSize.Width + 2);

// Display the selected text
MessageBox.Show("Selected Text = " + vt1.SelectedText);

// Print the selected text
vt1.PrintSelectedText();

// ...

// As an alternative to all of the above code, you can simply use...
vt1.PrintScreen();

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.Refresh Method

Refreshes the screen using current properties.

[Visual Basic]
Overrides Public Sub Refresh()
[C#]
public override void Refresh();

Remarks

The Resize method resizes the screen based on the Vt.Margin, Vt.Width, and Vt.Height properties.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.Resize Method ()

Resizes the screen using current properties.

[Visual Basic]
Public Sub Resize()
[C#]
new public void Resize();

Remarks

The Resize method resizes the screen based on the Vt.ScreenSize, Vt.Font, Vt.CharacterSize, and Vt.StatusLine properties.

NOTE! If you are using a docking technique (i.e. Vt.Dock != DockStyle.None) the Vt control will not be resized. In this case, you have to resize the parent container. See the sample applications included with the installation for a demonstration.

Example

[Visual Basic, C#] The following example demonstrates simple use of the AutoPrint feature.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Reset to the default font, size 15
vt1.SetDefaultFont(15)

' Resize the form based on the new font value.
vt1.Resize()
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Reset to the default font, size 15
vt1.SetDefaultFont(15);

// Resize the form based on the new font value.
vt1.Resize();

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace | Vt.Resize Overload List


ScrapeCells Method

PowerTCP Emulation for .NET

Vt.ScrapeCells Method

Retrieves information about the cells in the specified range.

Overload List

Retrieves information about the cells in the specified range.

public Cell[] ScrapeCells(int,int);

Retrieves information about the cells in the specified range.

public Cell[] ScrapeCells(int,int,int);

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.ScrapeCells Method (Int32, Int32)

Retrieves information about the cells in the specified range.

[Visual Basic]
Overloads Public Function ScrapeCells( _
ByVal offset As Integer, _
ByVal count As Integer _
) As Cell()
[C#]
public Cell[] ScrapeCells(
int offset,
int count
);

Parameters

offset
The character to begin scraping text from.
count
The number of characters to scrape.

Return Value

An array of Cell objects, describing each cell in the specified range.

Remarks

Use this method to retrieve an array of Cell objects describing a range of characters. Use the Cell object to discover information about the cell, such as the character contained within it, the formatting applied to it, etc.

Note, that the offset value is relative from the start of the buffer. For example, if you wished to scrape all of the characters in the scroll-back buffer, you could calculate the length of the characters in the scroll-back buffer by multiplying Vt.BufferRows (the number of rows in the scroll-back buffer) by Vt.ScreenSize.Width (the number of columns per row). Using this example, it is also necessary to add 2 to Vt.ScreenSize.Width before multiplying to account for an extra CrLf.

Example

[Visual Basic, C#] The following example demonstrates using the ScrapeCells method to discover info about a cell.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

Private Sub ShowCellInfo(ByVal offset As Integer)
   ' Scrape the row and column specified.
   Dim cells as Cell() = vt1.ScrapeCells(offset, 1)

   ' Display info about the cell.
   textBox1.Text = "Character: " & cells(0).Character
   textBox1.Text = textBox1.Text & " (" & CChar(cells(0).Character) & ")" & vbCrLf
   textBox1.Text = textBox1.Text & "Raw Character: " & cells(0).RawCharacter
   textBox1.Text = textBox1.Text & " (" & CChar(cells(0).RawCharacter) & ")" & vbCrLf
   textBox1.Text = textBox1.Text & "Background color: " & cells(0).BackColor & vbCrLf
   textBox1.Text = textBox1.Text & "Foreground color: " & cells(0).ForeColor & vbCrLf
   textBox1.Text = textBox1.Text & "Styles: " & cells(0).Styles
End Sub

' Use the following code to test the function

' Disable buffer
vt1.BufferRows = 0

' Clear the display
vt1.Clear()

' Add some dummy data
vt1.Write(Chr(27) + "[1mTest " + Chr(27) + "[0mdata" + Chr(27) + "[7m blah " + Chr(27) + "[0m")

' Call the function
ShowCellInfo(2)
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

private void ShowCellInfo(int offset)
{
   // Scrape the row and column specified.
   Cell[] cells = vt1.ScrapeCells(offset, 1);

   // Display info about the cell.
   textBox1.Text = "Character: " + cells[0].Character;
   textBox1.Text+= " (" + (char)cells[0].Character + ")" + "\r\n";
   textBox1.Text+= "Raw Character: " + cells[0].RawCharacter;
   textBox1.Text+= " (" + (char)cells[0].RawCharacter + ")" + "\r\n";
   textBox1.Text+= "Background color: " + cells[0].BackColor + "\r\n";
   textBox1.Text+= "Foreground color: " + cells[0].ForeColor + "\r\n";
   textBox1.Text+= "Styles: " + cells[0].Styles;
}

// Use the following code to test the function

// Disable buffer
vt1.BufferRows = 0;

// Clear the display
vt1.Clear();

// Add some dummy data
vt1.Write("\x1b[1mTest \x1b[0mdata\x1b[7m blah \x1b[0m");

// Call the function
ShowCellInfo(2);

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace | Vt.ScrapeCells Overload List


Vt.ScrapeCells Method (Int32, Int32, Int32)

Retrieves information about the cells in the specified range.

[Visual Basic]
Overloads Public Function ScrapeCells( _
ByVal row As Integer, _
ByVal col As Integer, _
ByVal count As Integer _
) As Cell()
[C#]
public Cell[] ScrapeCells(
int row,
int col,
int count
);

Parameters

row
The row to begin scraping on.
col
The column to begin scraping on.
count
The number of characters to scrape.

Return Value

An array of Cell objects, describing each cell in the specified range.

Example

[Visual Basic, C#] The following example demonstrates using the ScrapeCells method to discover info about a cell.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

Private Sub ShowCellInfo(ByVal row As Integer, ByVal col As Integer)
   ' Scrape the row and column specified.
   Dim cells as Cell() = vt1.ScrapeCells(row, col, 1)

   ' Display info about the cell.
   textBox1.Text = "Character: " & cells(0).Character
   textBox1.Text = textBox1.Text & " (" & CChar(cells(0).Character) & ")" & vbCrLf
   textBox1.Text = textBox1.Text & "Raw Character: " & cells(0).RawCharacter
   textBox1.Text = textBox1.Text & " (" & CChar(cells(0).RawCharacter) & ")" & vbCrLf
   textBox1.Text = textBox1.Text & "Background color: " & cells(0).BackColor & vbCrLf
   textBox1.Text = textBox1.Text & "Foreground color: " & cells(0).ForeColor & vbCrLf
   textBox1.Text = textBox1.Text & "Styles: " & cells(0).Styles
End Sub

' Use the following code to test the function

' Disable buffer
vt1.BufferRows = 0

' Clear the display
vt1.Clear()

' Add some dummy data
vt1.Write(Chr(27) + "[1mTest " + Chr(27) + "[0mdata" + Chr(27) + "[7m blah " + Chr(27) + "[0m")

' Call the function
ShowCellInfo(0, 3)
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

private void ShowCellInfo(int row, int col)
{
   // Scrape the row and column specified.
   Cell[] cells = vt1.ScrapeCells(row, col, 1);

   // Display info about the cell.
   textBox1.Text = "Character: " + cells[0].Character;
   textBox1.Text+= " (" + (char)cells[0].Character + ")" + "\r\n";
   textBox1.Text+= "Raw Character: " + cells[0].RawCharacter;
   textBox1.Text+= " (" + (char)cells[0].RawCharacter + ")" + "\r\n";
   textBox1.Text+= "Background color: " + cells[0].BackColor + "\r\n";
   textBox1.Text+= "Foreground color: " + cells[0].ForeColor + "\r\n";
   textBox1.Text+= "Styles: " + cells[0].Styles;
}

// Use the following code to test the function

// Disable buffer
vt1.BufferRows = 0;

// Clear the display
vt1.Clear();

// Add some dummy data
vt1.Write("\x1b[1mTest \x1b[0mdata\x1b[7m blah \x1b[0m");

// Call the function
ShowCellInfo(0, 3);

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace | Vt.ScrapeCells Overload List


ScrapeHtml Method

PowerTCP Emulation for .NET

Vt.ScrapeHtml Method

Returns an HTML representation of the VT data.

Overload List

Returns an HTML representation of the VT data.

public string ScrapeHtml(int,int);

Returns an HTML representation of the VT data.

public string ScrapeHtml(int,int,int);

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.ScrapeHtml Method (Int32, Int32)

Returns an HTML representation of the VT data.

[Visual Basic]
Overloads Public Function ScrapeHtml( _
ByVal offset As Integer, _
ByVal count As Integer _
) As String
[C#]
public string ScrapeHtml(
int offset,
int count
);

Parameters

offset
The character to begin returning HTML text from.
count
The number of characters to include.

Return Value

This method attempts to convert the VT data into an HTML representation. This is achieved by converting VT escape sequences into HTML tags. For example, if the Vt control detects that a character is bolded using VT escape sequences, these sequences are removed and replaced with the HTML <B> tag.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace | Vt.ScrapeHtml Overload List


Vt.ScrapeHtml Method (Int32, Int32, Int32)

Returns an HTML representation of the VT data.

[Visual Basic]
Overloads Public Function ScrapeHtml( _
ByVal row As Integer, _
ByVal col As Integer, _
ByVal count As Integer _
) As String
[C#]
public string ScrapeHtml(
int row,
int col,
int count
);

Parameters

row
The row to begin returning HTML text from.
col
The column to begin returning HTML text from.
count
The number of characters to include.

Return Value

This method attempts to convert the VT data into an HTML representation. This is achieved by converting VT escape sequences into HTML tags. For example, if the Vt control detects that a character is bolded using VT escape sequences, these sequences are removed and replaced with the HTML <B> tag.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace | Vt.ScrapeHtml Overload List


ScrapeText Method

PowerTCP Emulation for .NET

Vt.ScrapeText Method

Retrieves text (minus escape characters) from the Vt display.

Overload List

Retrieves text (minus escape characters) from the Vt display.

public string ScrapeText(int,int);

Retrieves text (minus escape characters) from the Vt display.

public string ScrapeText(int,int,int);

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.ScrapeText Method (Int32, Int32)

Retrieves text (minus escape characters) from the Vt display.

[Visual Basic]
Overloads Public Function ScrapeText( _
ByVal offset As Integer, _
ByVal count As Integer _
) As String
[C#]
public string ScrapeText(
int offset,
int count
);

Parameters

offset
The character to begin scraping text from.
count
The number of characters to scrape.

Return Value

A string representation of the scraped characters.

Remarks

This method retrieves all of the text that matches the specifies parameters, removing all escape characters. Note, that the offset value is relative from the start of the buffer. For example, if you wished to scrape all of the characters in the scroll-back buffer, you could calculate the length of the characters in the scroll-back buffer by multiplying Vt.BufferRows (the number of rows in the scroll-back buffer) by Vt.ScreenSize.Width (the number of columns per row). Using this example, it is also necessary to add 2 to Vt.ScreenSize.Width before multiplying to account for an extra CrLf.

Example

[Visual Basic, C#] The following example demonstrates simple text scraping.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Clear the display
vt1.Clear()

' Add some dummy data including escape sequences for formatting
vt1.Write(Chr(27) + "[1mTest " + Chr(27) + "[0mdata" + Chr(27) + "[7m blah " + Chr(27) + "[0m")

' Scrape the text
Dim s As String = vt1.ScrapeText(0, vt1.TextLength)

' Display the text, the escape sequences should be gone,
' leaving "Test data blah"
textBox1.Text = s.Trim()
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Clear the display
vt1.Clear();

// Add some dummy data including escape sequences for formatting
vt1.Write("\x1b[1mTest \x1b[0mdata\x1b[7m blah \x1b[0m");

// Scrape the text
string s = vt1.ScrapeText(0, vt1.TextLength);

// Display the text, the escape sequences should be gone,
// leaving "Test data blah"
textBox1.Text = s.Trim();

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace | Vt.ScrapeText Overload List


Vt.ScrapeText Method (Int32, Int32, Int32)

Retrieves text (minus escape characters) from the Vt display.

[Visual Basic]
Overloads Public Function ScrapeText( _
ByVal row As Integer, _
ByVal col As Integer, _
ByVal count As Integer _
) As String
[C#]
public string ScrapeText(
int row,
int col,
int count
);

Parameters

row
The row to begin scraping on.
col
The column to begin scraping on.
count
The number of characters to scrape.

Return Value

A string representation of the scraped characters.

Remarks

This method retrieves all of the text that matches the specifies parameters, removing all escape characters. Note, that the row/col values are relative from the start of the buffer. For example, if you wished to scrape all of the characters in the scroll-back buffer, you could calculate the length of the characters in the scroll-back buffer by multiplying Vt.BufferRows (the number of rows in the scroll-back buffer) by Vt.ScreenSize.Width (the number of columns per row). Using this example, it is also necessary to add 2 to Vt.ScreenSize.Width before multiplying to account for an extra CrLf.

Example

[Visual Basic, C#] The following example demonstrates simple text scraping.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Clear the display
vt1.Clear()

' Add some dummy data including escape sequences for formatting
vt1.Write(Chr(27) + "[1mTest " + Chr(27) + "[0mdata" + Chr(27) + "[7m blah " + Chr(27) + "[0m")

' Scrape the text
Dim s As String = vt1.ScrapeText(0, 0, vt1.TextLength)

' Display the text, the escape sequences should be gone,
' leaving "Test data blah"
textBox1.Text = s.Trim()
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Clear the display
vt1.Clear();

// Add some dummy data including escape sequences for formatting
vt1.Write("\x1b[1mTest \x1b[0mdata\x1b[7m blah \x1b[0m");

// Scrape the text
string s = vt1.ScrapeText(0, 0, vt1.TextLength);

// Display the text, the escape sequences should be gone,
// leaving "Test data blah"
textBox1.Text = s.Trim();

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace | Vt.ScrapeText Overload List


Vt.SetDefaultFont Method

Resets the font to its default value and applies the size change specified.

[Visual Basic]
Public Sub SetDefaultFont( _
ByVal pointSize As Single _
)
[C#]
public void SetDefaultFont(
float pointSize
);

Parameters

pointSize
The new size of the default font.

Remarks

This method simply provides an easy way to reset the font (as opposed to creating a new Font object and setting Vt.FontEx to it) to the default value of "VT220_ascii".

Example

[Visual Basic, C#] The following example demonstrates simple use of the AutoPrint feature.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Reset to the default font, size 15
vt1.SetDefaultFont(15)

' Resize the form based on the new font value.
vt1.Resize()
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Reset to the default font, size 15
vt1.SetDefaultFont(15);

// Resize the form based on the new font value.
vt1.Resize();

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Write Method

PowerTCP Emulation for .NET

Vt.Write Method

Displays the data contained within a byte array in the Vt window and interprets all escape sequences.

Overload List

Displays the data contained within a byte array in the Vt window and interprets all escape sequences.

public void Write(byte[]);

Displays the data contained within a byte array in the Vt window and interprets all escape sequences.

public void Write(byte[],int,int);

Displays the data contained within a stream in the Vt window and interprets all escape sequences.

public void Write(Stream);

Displays the data contained within a string in the Vt window and interprets all escape sequences.

public void Write(string);

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.Write Method (Byte[])

Displays the data contained within a byte array in the Vt window and interprets all escape sequences.

[Visual Basic]
Overloads Public Sub Write( _
ByVal data As Byte() _
)
[C#]
public void Write(
byte[] data
);

Parameters

data
The data to display.

Remarks

Use this method to process data received from a host, or VT formatted data from a file or other data source. The control interprets and displays the data using the terminal type specified in the Vt.TerminalType property.

Example

[Visual Basic, C#] The following example demonstrates displaying byte array data in the VT display.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Create some test data
Dim data As Byte() = System.Text.Encoding.Default.GetBytes("Test data" + vbCrLf)

' Write it to the Vt display
vt1.Write(data)
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create some test data
byte[] data = System.Text.Encoding.Default.GetBytes("Test data\r\n");

// Write it to the Vt display
vt1.Write(data);

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace | Vt.Write Overload List


Vt.Write Method (Byte[], Int32, Int32)

Displays the data contained within a byte array in the Vt window and interprets all escape sequences.

[Visual Basic]
Overloads Public Sub Write( _
ByVal data As Byte(), _
ByVal offset As Integer, _
ByVal count As Integer _
)
[C#]
public void Write(
byte[] data,
int offset,
int count
);

Parameters

data
The data to display.
offset
The offset to being displaying.
count
The count of bytes to display.

Remarks

Use this method to process data received from a host, or VT formatted data from a file or other data source. The control interprets and displays the data using the terminal type specified in the Vt.TerminalType property.

Example

[Visual Basic, C#] The following example demonstrates displaying byte array data in the VT display.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Create some test data
Dim data As Byte() = System.Text.Encoding.Default.GetBytes("Test data" + vbCrLf)

' Write it to the Vt display
vt1.Write(data, 0, data.Length)
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create some test data
byte[] data = System.Text.Encoding.Default.GetBytes("Test data\r\n");

// Write it to the Vt display
vt1.Write(data, 0, data.Length);

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace | Vt.Write Overload List


Vt.Write Method (Stream)

Displays the data contained within a stream in the Vt window and interprets all escape sequences.

[Visual Basic]
Overloads Public Sub Write( _
ByVal sourceStream As Stream _
)
[C#]
public void Write(
Stream sourceStream
);

Parameters

sourceStream
The Stream containing the data to display.

Example

[Visual Basic, C#] The following example demonstrates writing stream-based data to the Vt display.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Create a test stream filled with test data
Dim m As New System.IO.MemoryStream()
Dim data As Byte() = System.Text.Encoding.Default.GetBytes("Test data" + vbCrLf)
m.Write(data, 0, data.Length)
m.Position = 0

vt1.Clear()

' Write the stream data to the Vt.
vt1.Write(m)
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Create a test stream filled with test data
System.IO.MemoryStream m = new System.IO.MemoryStream();
byte[] data = System.Text.Encoding.Default.GetBytes("Test data\r\n");
m.Write(data, 0, data.Length);
m.Position = 0;

vt1.Clear();

// Write the stream data to the Vt.
vt1.Write(m);

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace | Vt.Write Overload List


Vt.Write Method (String)

Displays the data contained within a string in the Vt window and interprets all escape sequences.

[Visual Basic]
Overloads Public Sub Write( _
ByVal data As String _
)
[C#]
public void Write(
string data
);

Parameters

data
The data to display.

Example

[Visual Basic, C#] The following example demonstrates simple text scraping.

[Visual Basic]' Be sure to include "imports Dart.PowerTCP.Emulation;" at the top of your class.

' Clear the display
vt1.Clear()

' Add some dummy data including escape sequences for formatting
vt1.Write(Chr(27) + "[1mTest " + Chr(27) + "[0mdata" + Chr(27) + "[7m blah " + Chr(27) + "[0m")

' Scrape the text
Dim s As String = vt1.ScrapeText(0, 0, vt1.TextLength)

' Display the text, the escape sequences should be gone,
' leaving "Test data blah"
textBox1.Text = s.Trim()
[C#] // Be sure to include "using Dart.PowerTCP.Emulation;" at the top of your class.

// Clear the display
vt1.Clear();

// Add some dummy data including escape sequences for formatting
vt1.Write("\x1b[1mTest \x1b[0mdata\x1b[7m blah \x1b[0m");

// Scrape the text
string s = vt1.ScrapeText(0, 0, vt1.TextLength);

// Display the text, the escape sequences should be gone,
// leaving "Test data blah"
textBox1.Text = s.Trim();

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace | Vt.Write Overload List


Vt Events

The events of the Vt class are listed below. For a complete list of Vt class members, see the Vt Members topic.

Public Instance Events

AutoRepeatChanged | Raised when the host sends an instruction which changes the value of the Vt.AutoRepeat property.
AutoWrapChanged | Raised when the host sends an instruction which changes the value of the Vt.AutoWrap property.
BackColorChanged (inherited from Control) | Occurs when the value of the BackColor property changes.
BackgroundImageChanged (inherited from Control) | Occurs when the value of the BackgroundImage property changes.
BindingContextChanged (inherited from Control) | Occurs when the value of the BindingContext property changes.
CausesValidationChanged (inherited from Control) | Occurs when the value of the CausesValidation property changes.
ChangeUICues (inherited from Control) | Occurs when the focus or keyboard user interface (UI) cues change.
Click (inherited from Control) | Occurs when the control is clicked.
ContextMenuChanged (inherited from Control) | Occurs when the value of the ContextMenu property changes.
ControlAdded (inherited from Control) | Occurs when a new control is added to the ControlCollection .
ControlRemoved (inherited from Control) | Occurs when a control is removed from the ControlCollection .
CursorChanged (inherited from Control) | Occurs when the value of the Cursor property changes.
CursorKeysChanged | Raised when the host sends an instruction which changes the value of the Vt.CursorKeys property.
CursorPositionChanged | Raised when the host sends an instruction which changes the value of the Vt.CursorPosition property.
Disposed (inherited from Component) | Adds an event handler to listen to the Disposed event on the component.
DockChanged (inherited from Control) | Occurs when the value of the Dock property changes.
DoubleClick (inherited from Control) | Occurs when the control is double-clicked.
DragDrop (inherited from Control) | Occurs when a drag-and-drop operation is completed.
DragEnter (inherited from Control) | Occurs when an object is dragged into the control's bounds.
DragLeave (inherited from Control) | Occurs when an object is dragged out of the control's bounds.
DragOver (inherited from Control) | Occurs when an object is dragged over the control's bounds.
EnabledChanged (inherited from Control) | Occurs when the Enabled property value has changed.
Enter (inherited from Control) | Occurs when the control is entered.
FontChanged (inherited from Control) | Occurs when the Font property value changes.
ForeColorChanged (inherited from Control) | Occurs when the ForeColor property value changes.
GiveFeedback (inherited from Control) | Occurs during a drag operation.
GotFocus (inherited from Control) | Occurs when the control receives focus.
HandleCreated (inherited from Control) | Occurs when a handle is created for the control.
HandleDestroyed (inherited from Control) | Occurs when the control's handle is in the process of being destroyed.
HelpRequested (inherited from Control) | Occurs when the user requests help for a control.
ImeModeChanged (inherited from Control) | Occurs when the ImeMode property has changed.
Invalidated (inherited from Control) | Occurs when a control's display requires redrawing.
InverseChanged | Raised when the host sends an instruction which changes the value of the Vt.Inverse property.
KeyDown | Raised when the user presses a key.
KeyPadChanged | Raised when the host sends an instruction which changes the value of the Vt.KeyPad property.
KeyPress | Raised when the user presses a key.
KeyUp (inherited from Control) | Occurs when a key is released while the control has focus.
Layout (inherited from Control) | Occurs when a control should reposition its child controls.
Leave (inherited from Control) | Occurs when the input focus leaves the control.
Line | Raised when the cursor in the VT changes rows as the result of a new line.
LocalEchoChanged | Raised when the host sends an instruction which changes the value of the Vt.LocalEcho property.
LocationChanged (inherited from Control) | Occurs when the Location property value has changed.
LostFocus (inherited from Control) | Occurs when the control loses focus.
MouseDown (inherited from Control) | Occurs when the mouse pointer is over the control and a mouse button is pressed.
MouseEnter (inherited from Control) | Occurs when the mouse pointer enters the control.
MouseHover (inherited from Control) | Occurs when the mouse pointer hovers over the control.
MouseLeave (inherited from Control) | Occurs when the mouse pointer leaves the control.
MouseMove (inherited from Control) | Occurs when the mouse pointer is moved over the control.
MouseUp (inherited from Control) | Occurs when the mouse pointer is over the control and a mouse button is released.
MouseWheel (inherited from Control) | Occurs when the mouse wheel moves while the control has focus.
Move (inherited from Control) | Occurs when the control is moved.
NewLineChanged | Raised when the host sends an instruction which changes the value of the Vt.NewLine property.
Paint (inherited from Control) | Occurs when the control is redrawn.
ParentChanged (inherited from Control) | Occurs when the Parent property value changes.
PrintChanged | Raised when the host sends an instruction which changes the value of the Vt.Print property.
QueryAccessibilityHelp (inherited from Control) | Occurs when AccessibleObject is providing help to accessibility applications.
QueryContinueDrag (inherited from Control) | Occurs during a drag-and-drop operation and allows the drag source to determine whether the drag-and-drop operation should be canceled.
Resize (inherited from Control) | Occurs when the control is resized.
RightToLeftChanged (inherited from Control) | Occurs when the RightToLeft property value changes.
ScreenSizeChanged | Raised when the host sends an instruction which changes the value of the Vt.ScreenSize property.
ScrollTypeChanged | Raised when the host sends an instruction which changes the value of the Vt.ScrollType property.
SizeChanged (inherited from Control) | Occurs when the Size property value changes.
StyleChanged (inherited from Control) | Occurs when the control style changes.
SystemColorsChanged (inherited from Control) | Occurs when the system colors change.
TabIndexChanged (inherited from Control) | Occurs when the TabIndex property value changes.
TabsChanged | Raised when the host sends an instruction which changes the value of the Vt.Tabs property.
TabStopChanged (inherited from Control) | Occurs when the TabStop property value changes.
TerminalTypeChanged | Raised when the host sends an instruction which changes the value of the Vt.TerminalType property.
TextChanged (inherited from Control) | Occurs when the Text property value changes.
Validated (inherited from Control) | Occurs when the control is finished validating.
Validating (inherited from Control) | Occurs when the control is validating.
VisibleChanged (inherited from Control) | Occurs when the Visible property value changes.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.AutoRepeatChanged Event

Raised when the host sends an instruction which changes the value of the Vt.AutoRepeat property.

[Visual Basic]
Public Event AutoRepeatChanged As EventHandler
[C#]
public event EventHandler AutoRepeatChanged;

Remarks

When the Vt control receives an instruction to change the value of the AutoRepeat property, the Vt control first changes the value of this property, then raises the AutoRepeatChanged event. To defeat this change, simply implement this event and reset the value of the property to whatever you wish when the event is raised.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.AutoWrapChanged Event

Raised when the host sends an instruction which changes the value of the Vt.AutoWrap property.

[Visual Basic]
Public Event AutoWrapChanged As EventHandler
[C#]
public event EventHandler AutoWrapChanged;

Remarks

When the Vt control receives an instruction to change the value of the AutoWrap property, the Vt control first changes the value of this property, then raises the AutoWrapChanged event. To defeat this change, simply implement this event and reset the value of the property to whatever you wish when the event is raised.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.CursorKeysChanged Event

Raised when the host sends an instruction which changes the value of the Vt.CursorKeys property.

[Visual Basic]
Public Event CursorKeysChanged As EventHandler
[C#]
public event EventHandler CursorKeysChanged;

Remarks

When the Vt control receives an instruction to change the value of the CursorKeys property, the Vt control first changes the value of this property, then raises the CursorPositionChanged event. To defeat this change, simply implement this event and reset the value of the property to whatever you wish when the event is raised.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.CursorPositionChanged Event

Raised when the host sends an instruction which changes the value of the Vt.CursorPosition property.

[Visual Basic]
Public Event CursorPositionChanged As EventHandler
[C#]
public event EventHandler CursorPositionChanged;

Remarks

When the Vt control receives an instruction to change the value of the CursorPosition property, the Vt control first changes the value of this property, then raises the CursorPositionChanged event. To defeat this change, simply implement this event and reset the value of the property to whatever you wish when the event is raised.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.InverseChanged Event

Raised when the host sends an instruction which changes the value of the Vt.Inverse property.

[Visual Basic]
Public Event InverseChanged As EventHandler
[C#]
public event EventHandler InverseChanged;

Remarks

When the Vt control receives an instruction to change the value of the Inverse property, the Vt control first changes the value of this property, then raises the InverseChanged event. To defeat this change, simply implement this event and reset the value of the property to whatever you wish when the event is raised.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.KeyDown Event

Raised when the user presses a key.

[Visual Basic]
Public Event KeyDown As KeyEventHandler
[C#]
public event KeyEventHandler KeyDown;

Remarks

The KeyDown event is raised when a key is pressed and before the Vt.KeyPress event is raised. This event is useful for performing keymapping (mapping individual keys to any arbitrary character sequence). To do this, simply set e.Handled to true (notifying the Vt control that the key press was handled so the Vt control does not raise the KeyDown event) and send your own substituted character sequence.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.KeyPadChanged Event

Raised when the host sends an instruction which changes the value of the Vt.KeyPad property.

[Visual Basic]
Public Event KeyPadChanged As EventHandler
[C#]
public event EventHandler KeyPadChanged;

Remarks

When the Vt control receives an instruction to change the value of the KeyPad property, the Vt control first changes the value of this property, then raises the KeyPadChanged event. To defeat this change, simply implement this event and reset the value of the property to whatever you wish when the event is raised.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.KeyPress Event

Raised when the user presses a key.

[Visual Basic]
Public Event KeyPress As DataEventHandler
[C#]
public event DataEventHandler KeyPress;

Event Data

The event handler receives an argument of type DataEventArgs containing data related to this event. The following DataEventArgs property provides information specific to this event.

Property | Description
Bytes | Returns the data that was generated as the result of a key press.

Remarks

The KeyDown event is raised when a key is pressed and after the Vt.KeyDown event is raised. Within this event it is possible for a keypress to generate multiple bytes. ASCII characters are normally presented as a single byte, whereas function keys and others may generate byte arrays of greater length.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.Line Event

Raised when the cursor in the VT changes rows as the result of a new line.

[Visual Basic]
Public Event Line As DataEventHandler
[C#]
public event DataEventHandler Line;

Event Data

The event handler receives an argument of type DataEventArgs containing data related to this event. The following DataEventArgs property provides information specific to this event.

Property | Description
Bytes | Returns the data that was generated as the result of a key press.

Remarks

This event is useful for taking some action (such as capturing data to a file) for each new line displayed on the VT window.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.LocalEchoChanged Event

Raised when the host sends an instruction which changes the value of the Vt.LocalEcho property.

[Visual Basic]
Public Event LocalEchoChanged As EventHandler
[C#]
public event EventHandler LocalEchoChanged;

Remarks

When the Vt control receives an instruction to change the value of the LocalEcho property, the Vt control first changes the value of this property, then raises the LocalEchoChanged event. To defeat this change, simply implement this event and reset the value of the property to whatever you wish when the event is raised.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.NewLineChanged Event

Raised when the host sends an instruction which changes the value of the Vt.NewLine property.

[Visual Basic]
Public Event NewLineChanged As EventHandler
[C#]
public event EventHandler NewLineChanged;

Remarks

When the Vt control receives an instruction to change the value of the NewLine property, the Vt control first changes the value of this property, then raises the NewLineChanged event. To defeat this change, simply implement this event and reset the value of the property to whatever you wish when the event is raised.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.PrintChanged Event

Raised when the host sends an instruction which changes the value of the Vt.Print property.

[Visual Basic]
Public Event PrintChanged As EventHandler
[C#]
public event EventHandler PrintChanged;

Remarks

When the Vt control receives an instruction to change the value of the Print property, the Vt control first changes the value of this property, then raises the PrintChanged event. To defeat this change, simply implement this event and reset the value of the property to whatever you wish when the event is raised.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.ScreenSizeChanged Event

Raised when the host sends an instruction which changes the value of the Vt.ScreenSize property.

[Visual Basic]
Public Event ScreenSizeChanged As EventHandler
[C#]
public event EventHandler ScreenSizeChanged;

Remarks

When the Vt control receives an instruction to change the value of the ScreenSize property, the Vt control first changes the value of this property, then raises the ScreenSizeChanged event. To defeat this change, simply implement this event and reset the value of the property to whatever you wish when the event is raised.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.ScrollTypeChanged Event

Raised when the host sends an instruction which changes the value of the Vt.ScrollType property.

[Visual Basic]
Public Event ScrollTypeChanged As EventHandler
[C#]
public event EventHandler ScrollTypeChanged;

Remarks

When the Vt control receives an instruction to change the value of the ScrollType property, the Vt control first changes the value of this property, then raises the ScrollTypeChanged event. To defeat this change, simply implement this event and reset the value of the property to whatever you wish when the event is raised.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.TabsChanged Event

Raised when the host sends an instruction which changes the value of the Vt.Tabs property.

[Visual Basic]
Public Event TabsChanged As EventHandler
[C#]
public event EventHandler TabsChanged;

Remarks

When the Vt control receives an instruction to change the value of the Tabs property, the Vt control first changes the value of this property, then raises the TabsChanged event. To defeat this change, simply implement this event and reset the value of the property to whatever you wish when the event is raised.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Vt.TerminalTypeChanged Event

Raised when the host sends an instruction which changes the value of the Vt.TerminalType property.

[Visual Basic]
Public Event TerminalTypeChanged As EventHandler
[C#]
public event EventHandler TerminalTypeChanged;

Remarks

When the Vt control receives an instruction to change the value of the TerminalType property, the Vt control first changes the value of this property, then raises the TerminalTypeChanged event. To defeat this change, simply implement this event and reset the value of the property to whatever you wish when the event is raised.

See Also

Vt Class | Dart.PowerTCP.Emulation Namespace


Samples

The following samples are full applications which demonstrate usage of PowerTCP Emulation for .NET. The default directory for sample applications is C:\Program Files\PowerTCP\Emulation for .NET\Samples (where the install drive letter is C:\).

The following table shows the samples for this release and their default install locations.

Sample | Language | Location
Telnet Client (Internal) | VB.NET Windows Application C# Windows Application | C:\Program Files\PowerTCP\Emulation for .NET\Samples\VB.NET\Telnet Client (Internal) C:\Program Files\PowerTCP\Emulation for .NET\Samples\C#\Telnet Client (Internal)
Telnet Client (External) | VB.NET Windows Application C# Windows Application | C:\Program Files\PowerTCP\Emulation for .NET\Samples\VB.NET\Telnet Client (External) C:\Program Files\PowerTCP\Emulation for .NET\Samples\C#\Telnet Client (External)
Screen Scrape Sample | VB.NET Windows Application C# Windows Application | C:\Program Files\PowerTCP\Emulation for .NET\Samples\VB.NET\Scrape C:\Program Files\PowerTCP\Emulation for .NET\Samples\C#\Scrape

Related Sections

Getting Started
Provides an overview of PowerTCP Emulation for .NET and discusses such topics as distribution, licensing, and support.
Using PowerTCP within Visual Studio .NET
Demonstrates how to create a project and add a PowerTCP component.
Using the Vt Component
Discusses how to use the Vt component to display data.
Using Events in PowerTCP
Discusses how to use the events provided by PowerTCP Emulation for .NET.
Reference
Provides a language/syntax reference for PowerTCP Emulation for .NET.

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Telnet Client (Internal)

Demonstrates a simple emulator application which communicates with remote servers by using the internal Telnet component (exposed by the Vt.Telnet property), then displays the data using the VT control.

Requirements

Components: Dart.PowerTCP.Emulation.dll, Dart.PowerTCP.Telnet.dll

References: Dart.PowerTCP.Emulation.Forms.dll

Location

C:\Program Files\PowerTCP\Emulation for .NET\Samples\VB.NET\Telnet Client (Internal)

--or--

C:\Program Files\PowerTCP\Emulation for .NET\Samples\C#\Telnet Client (Internal)

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Telnet Client (External)

Demonstrates a simple emulator application which communicates with remote servers by using the Telnet component, then displays the data using the VT control.

Requirements

Components: Dart.PowerTCP.Emulation.dll, Dart.PowerTCP.Telnet.dll

References: Dart.PowerTCP.Emulation.Forms.dll

Location

C:\Program Files\PowerTCP\Emulation for .NET\Samples\VB.NET\Telnet Client (External)

--or--

C:\Program Files\PowerTCP\Emulation for .NET\Samples\C#\Telnet Client (External)

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Screen Scrape Sample

Demonstrates how to use the Vt control without the Telnet control to display and screen scrape VT formatted text.

Requirements

Components: Dart.PowerTCP.Emulation.dll, Dart.PowerTCP.Telnet.dll

References: Dart.PowerTCP.Emulation.Forms.dll

Location

C:\Program Files\PowerTCP\Emulation for .NET\Samples\VB.NET\Scrape

--or--

C:\Program Files\PowerTCP\Emulation for .NET\Samples\C#\Scrape

See Also

Using PowerTCP in VS.NET | Using the Vt Control | Emulation for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Welcome to PowerTCP Telnet for .NET

PowerTCP Telnet for .NET

PowerTCP Telnet for .NET

PowerTCP Telnet for .NET fills the TELNET and remote access communication gap in the .NET Framework by providing stream-based TELNET communication that can be plugged into any .NET technology. Advanced options include autologin capability, easy option negotiation configuration, and support for RSH, REXEC, and RLOGIN.

In The PowerTCP Telnet for .NET Documentation

Getting Started
Provides an overview of PowerTCP Telnet for .NET and discusses such topics as distribution, licensing, and support.
Using PowerTCP Within Visual Studio .NET
Demonstrates how to create a project and add a PowerTCP component.
Using The Telnet And Remote Access Components
Demonstrates how to use the Telnet, Rlogin, Rexec, and Rsh components.
Using Events In PowerTCP
Discusses the methodology behind the event implementation for PowerTCP Telnet for .NET, including step-by-step tutorials for implementing your own events.
Reference
Provides a language/syntax reference for PowerTCP Telnet for .NET
Samples
Describes the samples that are installed with PowerTCP Telnet for .NET.

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Getting Started

PowerTCP Telnet for .NET is a complete suite of classes that enable the integration of TELNET and remote access (REXEC, RSH, RLOGIN) communications into any .NET application. This topic, and related subtopics, address issues such as licensing, distribution, and support for PowerTCP Telnet for .NET. To find a tutorial or walkthrough pertaining to usage of PowerTCP Telnet for .NET, see Documentation Map. For a programmer's reference of the classes used by the PowerTCP Telnet for .NET, see Reference topic.

In This Section

Documentation Map
Provides a good navigational aid to quickly find the topic you want.
Requirements
Discusses the requirements needed to use PowerTCP Telnet for .NET.
License Installation
Provides step-by-step instructions on installing a license.
Trial Operation
Provides an overview on using PowerTCP Telnet for .NET in trial mode.
Deployment in ASP.NET
Discusses the extra steps that are required to distribute an application in ASP.NET.
Support
Provides an overview of the support options that are available for this product.
Protocol Overview
Provides a brief introduction to the TELNET protocol.

Related Sections

Using PowerTCP Within Visual Studio .NET
Demonstrates how to create a project and add a PowerTCP component.
Using The Telnet And Remote Access Components
Demonstrates how to use the Telnet, Rlogin, Rexec, and Rsh components.
Using Events In PowerTCP
Discusses the methodology behind the event implementation for PowerTCP Telnet for .NET, including step-by-step tutorials for implementing your own events.
Reference
Provides a language/syntax reference for PowerTCP Telnet for .NET
Samples
Describes the samples that are installed with PowerTCP Telnet for .NET.

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


PowerTCP Telnet for .NET Documentation Map

The following topics were designed to get you quickly developing using PowerTCP Telnet for .NET

To | See
Learn how to create a project in Visual Studio .NET. | Creating A Project
Learn how to add a component to a form. | Creating An Instance Of A Component Using Visual Studio .NET
Learn how to add a component to a project as a reference. | Adding A Component As A Reference Within Visual Studio .NET
Learn how to use the Telnet component. | Using The Telnet Component
Learn how to configure option negotiation using the Telnet component. | Using The Telnet Component
Learn how to use the Rlogin component | Using The Rlogin Component
Learn how to use the Rexec and Rsh components | Using The Rexec/Rsh Components

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Requirements

In order to use PowerTCP Telnet for .NET you must have the following:

  • Microsoft Visual Studio .NET (Recommended)
  • .NET Framework

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


License Installation

Your PowerTCP License Agreement provides you with a single-seat development license and the right to distribute PowerTCP classes with NO ROYALTIES of any kind. Some PowerTCP classes are marked as licensed. This topic covers:
  • Trial Installation
  • Installing a Fully Licensed PowerTCP Product
  • Re-installing a PowerTCP Product
  • License Details

Trial Installation

Installing a PowerTCP product as a fully–functional trial involves running the setup program (available from www.dart.com) without completing the Registration process. The trial will operate for 30 days after installation. Proceed to step 2 of Installing a Fully Licensed PowerTCP Product when you are ready to license the product.

See Trial Operation for more information.

Installing a Fully Licensed PowerTCP Product

Once you have downloaded the latest version, complete the following steps to register your PowerTCP product:

  1. From the Start menu, select Programs, select PowerTCP, select the PowerTCP product you downloaded, and then click Registration.
  2. In the PowerTCP Registration dialog box, click Register.
  3. Enter your Serial Number, First Name, Last Name, and Organization information.
  4. Click Next.
  5. Enter your Email Address, Purchased From, and Purchase Date information.
  6. Click Next.
  7. Verify that the information is correct, and then click Next.
  8. When the registration process is complete, click Exit. (Note: Clicking Done at this step displays your currently registered PowerTCP product. Click Exit to complete the registration process and close the dialog box.)
If you do not have Internet Access on your development machine, please follow these instructions:
  1. From the Start menu, select Programs, select PowerTCP, select the PowerTCP product you downloaded, and then click Registration.
  2. In the PowerTCP Registration dialog box, click Edit.
  3. Enter your serial number in the Serial # field.
  4. Write down the number in the Key field.
  5. On a machine that has Internet access, log on to the Dart registration page (http://www.dart.com/register/).
  6. Enter all required information. Required information is bolded. The Key is the number you wrote down in Step 4.
  7. Click Submit. A seven-digit registration code should appear.
  8. On your machine (the machine on which you completed Steps 1-4), if necessary, access the PowerTCP Registration dialog box to display the Currently Registered Products area containing the Key number.
  9. Enter your serial number and the seven-digit registration number you obtained in Step 6.
  10. Click Add.
  11. Click Exit.

After either of the two registration procedures are complete, your PowerTCP product appears in the Registered Tools field at the top of the registration form. Make sure you recompile your application after you register the PowerTCP product.

If you do not register your PowerTCP product at this point, it will operate as a trial.

Re-installing a PowerTCP Product

The Key provided by the Registration Program is derived from a system number that is changed when the C: drive is reformatted. If you reformat your hard disk and need to re-install your PowerTCP product, follow the steps in Installing a Fully Licensed PowerTCP Product. A new Registration Number will be generated.

License Details

When you insert a PowerTCP component into a project, most development environments verify that the class is licensed for development. The component will work if you correctly entered the PowerTCP product Serial Number. See Installing a Fully Licensed PowerTCP Product for more information. When you compile your application, the development environment requests this Serial Number and embeds it in the application. When users run your application, the application submits this Serial Number to the class and the Serial Number is checked for validity. If the Serial Number is correct, then the application runs. This verification process occurs automatically.

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Trial Operation

If you install a PowerTCP product without registering a Serial Number, it operates as a fully–functional trial for up to 30 days. If you need more time to evaluate the product, contact the Sales Department at sales@dart.com.

Trial Notification in Development Mode

Trial notification does not occur during design-time.

Trial Notification During Run-Time

PowerTCP products request a Serial Number when you compile your application. A dialog box appears warning you that the component is not licensed for deployment. Do not distribute your application using a trial product—the component will not work after the trial period! However, you may test your application for the duration of your trial period, during which time trial notification will occur with Windows applications. No trial notification will occur with Web applications so the application can run unhindered. Please be aware that the component will cease to function after the trial period has expired.

See License Installation for more information on product registration.

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Deployment In ASP.NET

To deploy a licensed ASP.NET Web Application or Web Service, follow these steps.

  1. Compile the ASP.NET application on a licensed development machine.
  2. If you are instantiating the component dynamically, be sure to include a licenses.licx file (see the Creating The Licenses.licx File topic for more information.
  3. Copy the contents of the bin folder and the ASP.NET source files (such as .aspx files) to the server that will be hosting the application.
  4. Create a virtual directory pointing to the folder containing the Web Application or Web Service.

Note: It is not necessary for the deployment server to be licensed or to contain a copy of a license in its registry.

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Support Options

Our mission at Dart is to deliver high quality Internet connectivity solutions to Internet application developers. Our goal is to supplement these solutions with timely support resources that can help at many different levels.

Related Links (you have an active connection to the Internet to view these links).

Paid Support Options
Discusses the paid support options available from single incident support to comprehensive support subscriptions.
Free Support Options
Provides access to free materials to help your development, including FAQS, online help files, tutorials, code snippets, online asp samples, and a free support forum.
Support Forum
Provides access to our support forum, monitored by our own development staff as time permits.
Dart Solutions
Discusses the custom development support offered by Dart Solutions.

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Protocol Overview

The following information attempts to give a basic understanding of the TELNET protocol and related concepts. This topic DOES NOT attempt to demonstrate usage of PowerTCP Telnet for .NET. For information of this type, see either the Documentation Map or PowerTCP Telnet for .NET Reference.

This topic covers:

  • Protocol Overview
  • Telnet Connections
  • Network Virtual Terminal
  • Binary Data
  • Option Negotiation

Protocol Overview

Telnet is a data communications protocol—a set of rules for communications between computers. TELNET stands for Telecommunications Network Protocol. TELNET communication works between different types of computers and operating systems because the protocol is the same for all systems. TELNET is often used for remote login—accessing one computer from another. A typical TELNET application would use the TELNET protocol to move data between a terminal emulator and a UNIX server (host).

Many host computers support the TELNET protocol. The main use is online terminal communications; you can use TELNET to log in to a remote computer and issue commands just as if you were at the remote computer itself. You can also use TELNET to access remote databases, control other computers, distribute work among multiple computers, and remotely execute many applications.

Telnet is similar to TCP; in fact, it is built upon it. TELNET provides additional features that make it an upper-layer protocol. Using TELNET, both ends of a connection send data to each other. Typically, a terminal sends commands to a host, and the host responds with messages or data. For example, a user at a terminal may type "help" and the host may respond with "Type a command to get help on".

Telnet provides option negotiation as a method for establishing conventions between two computers. During a session, either computer may send the other a command, requesting or volunteering a specific option. A typical option is echoing. The process of option negotiation determines if either computer will support echoing.

Back to Top

Telnet Connections

Connections are made on a port, which is a method of distinguishing multiple communications on a single computer. Most TELNET connections are made to port 23, the standard TELNET port.

To make a connection you must specify a port and host name or address to connect to. All computers on a network have an IP address, a number that distinguishes them from other computers. All IP addresses have the following same format:

nnn.nnn.nnn.nnn

where each nnn is a number from 0 to 255 (except for the first n, which may be from 0 to 247).

A typical IP address might be 129.229.1.2. Most networks also support computer names, where the network will translate a name (such as "server3") into an IP address.

Back to Top

Network Virtual Terminal

The Network Virtual Terminal (NVT) is a concept TELNET uses to represent both computers in a connection. The NVT is an imaginary character-based device with a keyboard and a printer (input and output). Incoming data goes to the printer, and input from the keyboard goes to the other end of the TELNET connection. Both ends of a TELNET connection must support the concept of an NVT.

The NVT supports the 7-bit character set known as NVT ASCII. NVT ASCII is the same as normal ASCII text, except that only 7 bits represent the character. The eighth high bit of the byte must be set to 0. In NVT ASCII, an end of line is represented by a two-character sequence CR, LF (carriage return, linefeed).

Both ends of a TELNET connection map their own terminal device characteristics to and from the NVT. For example, a program must change all 8-bit ASCII characters to the NVT character set. The NVT is intended to strike a balance between being overly restrictive (not providing some computers a rich enough vocabulary for mapping into their local character sets) and being overly inclusive (penalizing users with modest terminals).

Please refer to RFC 854 for more information on the NVT.

Back to Top

Binary Data

PowerTCP provides full support for binary data transmission. The Telnet.Send method applies the following basic TELNET encoding rules:

  1. Every byte of value 255 (IAC) is doubled up into a two-byte (255, 255) value.
  2. Every byte of value 13 (CR) not followed by a byte of value 10 (LF) is transformed into a two-byte (13, 0) value.

For all data received using Telnet.Receive, the reciprocal transformation takes place within the Telnet component. This mechanism, established by RFC 854, enables the transmission of 8-bit binary data over a single TELNET channel.

There is also the "TransmitBinary" option that can be easily set using the Binary property of the TELNET component. When set to RequestOn, the "TransmitBinary" option is negotiated for both directions. When in this mode, a naked CR is not padded with a NULL after it when data is sent. When data is received, any CR NULL encountered is used unaltered. All other padding (such as the doubling of IAC bytes) remains the same.

Back to Top

Option Negotiation

Option negotiation is the process of two computers agreeing on what features they will or will not provide. Each computer may send a command to the other, and each may respond to commands. A typical option negotiation session may occur as follows (although over 40 different options might be negotiated):

Computer A | Computer B
1. I will echo back what you send to me. |
 | 2. OK, Do echo back what I send to you.
3. Do suppress go–aheads. |
 | 4. No, I won't suppress go–aheads.

Either computer may initiate option negotiation. One computer may request that the other computer support or not support an option, or that it will or won't support an option. The other computer may then respond that it will or won't support an option, or request that the other computer support or not support an option. The following table describes the four option negotiation commands:

Command | Description
WILL | The sender wants to support the option
WONT | The sender will not support the option
DO | The sender wants the receiver to support the option
DONT | The sender wants the receiver to not support the option

The different pairs of commands and responding commands follow:

Command | Response | Option Used
WILL I will support this option | DO I do support this option | Yes
WILL I will support this option | DONT No, don't support it | No
WONT I won't support this option | DONT OK, don't support it | No
DO Do support this option | WILL OK, I will support it | Yes
DO Do support this option | WONT No, I won't support it | No
DONT Don't support this option | WONT OK, I won't support it | No

Note If a computer does not want an option supported (WONT/DONT), then the other computer must comply, responding with a DONT or WONT.

Telnet also provides suboption negotiation—negotiating details about a specific option. An example is the "terminal type" option. For both computers to decide to support the same terminal type, instead of using a different option for each individual terminal type, use a suboption. A typical suboption negotiation is shown below:

Computer A | Computer B
1. I will support different terminal types. |
 | 2. OK, Do support different terminal types.
3. OK, send your terminal type suboption. |
 | 4. My terminal type suboption is "IBMPC".

Option negotiation and suboption negotiation makes TELNET very flexible and adaptable to many different terminal configurations. Refer to the applicable RFCs for more information on TELNET and TELNET option negotiation.

Back to Top

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Using PowerTCP Within Visual Studio .NET

PowerTCP Telnet for .NET is a complete suite of classes which enable the integration of TELNET and other remote access protocols like RSH (remote shell), REXEC (remote execute) and RLOGIN (remote login) into any .NET application. This topic and associated subtopics are mostly prerequisite to the usage of PowerTCP Telnet for .NET. For example, this topic illustrates such things as basic usage within Visual Studio.NET and how to add components as a reference. If you are already familiar with these tasks, you may benefit more by examining other topics.

In This Section

Creating A Project
This topic demonstrates how to create a new Windows project in Visual Studio .NET.
Creating An Instance Of A Component Within Visual Studio .NET
This topic demonstrates how to create and use a component using Visual Studio .NET.
Adding A Component As A Reference
This topic demonstrates how to add a component as a reference using Visual Studio .NET.
Creating The Licenses.licx File
This topic demonstrates how to create the licenses.licx file. This is only necessary when adding the component as a reference.
Using A PowerTCP Component In Your Own Custom Dll
This topic discusses how licensing works when creating custom dlls which use PowerTCP dlls.
Synchronous Vs Asynchronous Use
This topic discusses the benefits and uses for synchronous and asynchronous methods.

Related Sections

Getting Started
Provides an overview of PowerTCP Telnet for .NET and discusses such topics as distribution, licensing, and support.
Using The Telnet And Remote Access Components
Demonstrates how to use the Telnet, Rlogin, Rexec, and Rsh components.
Using Events In PowerTCP
Discusses the methodology behind the event implementation for PowerTCP Telnet for .NET, including step-by-step tutorials for implementing your own events.
Reference
Provides a language/syntax reference for PowerTCP Telnet for .NET.
Samples
Describes the samples that are installed with PowerTCP Telnet for .NET.

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Creating A Project

The following steps provide a walkthrough to create a project in Visual Studio.NET. Although PowerTCP Telnet for .NET can be used in your preferred environment on any machine that has the .NET Framework installed, the recommended method is to use the Visual Studio .NET environment.

To create a project in Visual Studio .NET, use the following steps:

  1. Start Visual Studio .NET.
  2. From the File menu, choose New, and then choose Project.
  3. From the resulting dialog box, choose either Visual C# Projects or Visual Basic Projects and then choose Windows Application. Alternatively, if you wish to create an ASP.NET web application, you can choose ASP.NET Web Application. Specify a name and a location for the project, and then click OK.

  4. After these steps have been completed, the project is created.

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Creating An Instance Of A Component Using Visual Studio .NET

Although PowerTCP Telnet for .NET can be used in your preferred environment on any machine that has the .NET Framework installed, the recommended method is to use the Visual Studio .NET environment.

To create a component within Visual Studio .NET, use the following steps (the following steps demonstrate using the Telnet component):

  1. Create a project as described in Creating A Project .
  2. Add the Telnet component to the form. To do this, right-click on the ToolBox and choose Customize ToolBox. If the ToolBox is not visible, navigate to the View menu and choose ToolBox.

  3. From the resulting dialog box, choose the .NET Framework Components tab, then scroll until you find the Telnet component (see the screen shot below). Check the checkbox next to it and select OK.

  4. Click the Telnet component icon on the ToolBox, and "drag" an instance of it onto the form. The Visual Studio .NET environment will automatically create and instantiate an instance of the Telnet component within your code.
  5. Make a quick application to test. Drag a button onto the form.
  6. Add the following code to the button "on-click" event handler.
    7. [C#]
// Connect to a server
telnet1.Connect("myserver");

// Receive data (probably a login prompt)
Segment seg = telnet1.Receive();
Debug.WriteLine("Here is the data: " + seg.ToString());

telnet1.Close();
[Visual Basic]
' Connect to a server
Telnet1.Connect("myserver")

' Receive data (probably a login prompt)
Dim seg As Segment = Telnet1.Receive()
Debug.WriteLine("Here is the data: " + seg.ToString())

Telnet1.Close()
  7. Navigate to the Debug menu and choose Start. The app will compile and execute.

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Adding A Component As A Reference Within Visual Studio .NET

When using Visual Studio .NET, the components included in PowerTCP Telnet for .NET can either be used as a component (see Using PowerTCP Within Visual Studio .NET for more information) or added as a reference. If you are using one of the components as a reference, there are a few extra steps you must take, namely:

  • You must instantiate your own event handlers.
  • You must create and add a licenses.licx file to the project.
The following steps illustrate how to add a component as a reference within Visual Studio .NET

To add the a component as a reference within Visual Studio .NET, use the following steps (the following steps demonstrate adding the Telnet component):

  1. Create a project as described in Creating A Project .
  2. Add the Telnet component as a reference. To do this right-click the References folder in the Solution Explorer and choose Add Reference (see the screen shot below). If the Solution Explorer is not visible, navigate to the View menu and choose Solution Explorer.

  3. You must add a licenses.licx file to the project. (See Creating The Licenses.licx File for more information).
  4. Make a quick application to test. Drag a button onto the form.
  5. Create an instance of the Telnet component within the button "on-click" event handler.
    6. [C#]
Dart.PowerTCP.Telnet.Telnet telnet1 = new Dart.PowerTCP.Telnet.Telnet();
[Visual Basic]
Dim Telnet1 as New Dart.PowerTCP.Telnet.Telnet()
  6. Add the following code to the button "on-click" event handler immediately after the code to create the Telnet component.
    7. [C#]
// Connect to a server
telnet1.Connect("myserver");

// Receive data (probably a login prompt)
Segment seg = telnet1.Receive();
Debug.WriteLine("Here is the data: " + seg.ToString());

telnet1.Close();
[Visual Basic]
' Connect to a server
Telnet1.Connect("myserver")

' Receive data (probably a login prompt)
Dim seg As Segment = Telnet1.Receive()
Debug.WriteLine("Here is the data: " + seg.ToString())

Telnet1.Close()
  7. Add a licenses.licx file to the project as described in Creating The Licenses.licx File.
  8. Navigate to the Debug menu and choose Start. The application will compile and execute.
  9. Note: This example shows usage without events. If you use a component as a reference you will have to create your own event handlers. To do this, see the "Using Events When Using A Component As A Reference" topic.

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Creating The Licenses.licx File

Note: If you are creating a component by dragging it from the toolbox, you do not need to create a licenses.licx file, as one will be created by the environment. These steps apply only if you are using a component as a reference, or from a non-Visual Studio .NET environment.

To create a licenses.licx file, use the following steps (This example demonstrates using the Telnet component).

  1. Start a new application in Visual Studio .NET and add the Telnet component as a reference.
  2. In the Solution Explorer, right-click the project name, choose Add, then Add New Item.
  3. From the resulting dialog box, choose Text File and name the file "licenses.licx". Click Open.
  4. Type the following in the licenses.licx file

    Dart.PowerTCP.Telnet.Telnet, Dart.PowerTCP.Telnet

    and save the file. You should now be able to compile and run a project that uses the Telnet component as a reference.

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Using a PowerTCP Component In Your Own Custom DLL

PowerTCP components can be used within a standard desktop application (EXE), a Web Service, a Windows Service, an ASP.NET application, and your own custom dynamic-link library (DLL). It is not necessary to provide licensing information for the custom dll, however it is necessary for any application which uses the custom dll. For example, if you have a dll ("Helper.dll") that uses a PowerTCP component it is not necessary to provide licensing info for the dll. However, if you have an an application ("App1.exe") that references "Helper.dll", the application will have to have a "licenses.licx" file containing the component information for the PowerTCP component (see Creating The Licenses.licx File for more information about creating "licenses.licx" files). In addition, "App1.exe" must be compiled on a machine that has a properly registered PowerTCP component.

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Synchronous Versus Asynchronous Methods

The decision of whether to use synchronous or asynchronous methods can be crucial and have an impact on the complexity of your code and the user experience.

The following lists discuss some of the characteristics of synchronous and asychronous methods in PowerTCP.

Synchronous Methods

  • Are easier to implement and use than asynchronous.
  • Do not require an event to implement.
  • Results are returned directly from the method call.
  • Error handling occurs during the method call.

Asynchronous Methods

  • Occur on a new thread.
  • Are slightly more difficult to implement and use than synchronous.
  • Must have an event handler to handle the response.
  • Results are returned to the event handler.
  • Error handling occurs within the associated event handler.

Most applications written with PowerTCP will be synchronous. The reasons for this are not purely due to the ease-of-use of synchronous methods. Synchronous methods are ideal for automated processes that can execute a blocking method for a period of time. In addition, synchronous methods can work well for interactive applications. The Object.DoEvents property controls the processing of user interface messages while a synchronous method is executing. This means that while a synchronous method is executing, other portions of the application will be able to respond to events (for example, button or menu clicks).

Asynchronous methods, on the other hand, provide a great deal of power. When an asynchronous method is called, the method will execute on a thread separate from the calling thread. Such operation is useful when an action is time consuming and other code needs to execute without waiting for the intial operation to complete. In addition, the user interface will be most responsive when asynchronous methods are used. Asynchronous methods are generally required for interactive on-line applications such as emulators, where received data must be displayed whenever it arrives.

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Using The Telnet And Remote Access Components

PowerTCP Telnet for .NET can be used to integrate TELNET and other remote access protocols like RSH (remote shell), REXEC (remote execute) and RLOGIN (remote login) into any .NET application. The following topics provide step-by-step walthroughs demonstrating how integrating these protocols into your .NET application can be achieved by using the components included with PowerTCP Telnet for .NET.

In This Section

Telnet Component Basic Usage
Provides a step-by-step walkthrough demonstrating how to send and receive data using the Telnet component.
Rlogin Component Basic Usage
Provides a step-by-step walkthrough demonstrating how to send and receive data using the Rlogin component.
Rexec/Rsh Basic Usage
Provides a step-by-step walkthrough demonstrating how to execute remote commands using the Rexec and Rsh components.
Using Asynchronous Methods
Provides a step-by-step walkthrough demonstrating how to use asynchronous methods when using PowerTCP Telnet for .NET.

Related Sections

Getting Started
Provides an overview of PowerTCP Telnet for .NET and discusses such topics as distribution, licensing, and support.
Using PowerTCP Within Visual Studio .NET
Demonstrates how to create a project and add a PowerTCP component.
Using Events In PowerTCP
Discusses the methodology behind the event implementation for PowerTCP Telnet for .NET, including step-by-step tutorials for implementing your own events.
Reference
Provides a language/syntax reference for PowerTCP Telnet for .NET.
Samples
Describes the samples that are installed with PowerTCP Telnet for .NET.

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Telnet Component Basic Usage

The following examples are intended to serve as a basic primer, demonstrating the most simple cases of sending and receiving data using the Telnet component.

Example 1: Simple Telnet communication with default settings

By default, the Telnet component will automatically attempt to negotiate several of the most commonly used options such as SuppressGoAheads (client and server), WindowSize (client), and TerminalType (client). Option negotiation will automatically occur after the Telnet component connects to the remote host. The following example demonstrates establishing a TELNET connection and sending and receiving data.

To quickly get started using the Telnet component.

  1. Create a new Windows application in Visual Studio .NET.
  2. Add the Telnet component to the new form. For instructions on how to do this see Creating An Instance Of A Component Using Visual Studio .NET
  3. Add a button to the form.
  4. Connect to the server using the Login method. This will automatically issue the specified username and password and will read until the specified command prompt is found. If you do not wish to use this automated behavior, simply use Connect and use Receive to receive prompts from the server and Send to send commands to the server.
    [Visual Basic]
' ReceiveTimeout must be set to a positive value before using the Login method.
Telnet1.ReceiveTimeout = 3000

' Connect and login to the Telnet server
Telnet1.Login("myserver", "myusername", "mypassword", "$")
[C#]
// ReceiveTimeout must be set to a positive value before using the Login method.
telnet1.ReceiveTimeout = 3000;

// Connect and login to the Telnet server
telnet1.Login("myserver", "myusername", "mypassword", "$");
  5. Once login has succeeded, the Telnet component should be in a state in which it is ready to send commands. For the purposes of this simple walkthrough, simply send a PWD command to cause the server to print it's working directory.
    [Visual Basic]
' Send PWD command
Telnet1.Send("PWD" + vbCrLf)
[C#]
// Send PWD command
telnet1.Send("PWD\r\n");
  6. Now receive the response from the server.
    [Visual Basic]
' Receive response
Dim s as String = Telnet1.WaitFor("$ ")

' Display the response
Debug.WriteLine(s)
[C#]
// Receive response
string s = telnet1.WaitFor("$ ")

// Display the response
Debug.WriteLine(s);
  7. Close the connection (you could send an "EXIT" command first, but this example demonstrates an abrupt close).
    [Visual Basic]
' Close the connection
Telnet1.Close()
[C#]
// Close the connection
telnet1.Close();
  8. Compile and run the application.

Example 2: Customizing option negotiation

The above example demonstrates using default option negotiation but it is quite easy to customize the option negotiation. Client options are represented by the Telnet.ClientOptions collection and server options are represented by the Telnet.ServerOptions collection. For an option to be part of the negotiation, an Option object representing the option simply has to be added to one of these collections. As stated in Example 1 above, these collections are initialized with a default set of commonly used Option objects. To determine if an Option is used or not, simply look at the State property. The default Options will all have Option.State = RequestOn, signifying that the option will be requested when option negotiation begins. Once option negotiation has completed the Option.State will either be OptionState.On, signifying that the option has been successfully negotiated and accepted by both sides of the connection or it will be OptionState.Off, signifying that the option was not successfully negotiated and accepted by both sides of the connection.

This example demonstrates "removing" a default option and requesting a new option.

  1. Follow the steps in Example 1 to create a new project, add a Telnet component, and add a button to the form. Place the following code in the button's onClick event.
  2. In this example, for demonstration purposes, we wish to "remove" the TerminalType option on the client. This is accomplished by removing the Option from the collection.
    [Visual Basic]
' Cause the client to refuse the TerminalType option if offered by the server
Telnet1.ClientOptions.Remove(Telnet1.ClientOptions(OptionCode.TerminalType))
[C#]
// Cause the client to refuse the TerminalType option if offered by the server
telnet1.ClientOptions.Remove(telnet1.ClientOptions[OptionCode.TerminalType]);
  3. Now add a new Option. The Option will be automatically added with Option.State = OptionState.RequestOn.
    [Visual Basic]
' Request that server enable the Echo option
Telnet1.ServerOptions.Add(New Option(OptionCode.Echo))
[C#]
// Request that server enable the Echo option
telnet1.ServerOptions.Add(new Option(OptionCode.Echo));
  4. As in Example 1, login to the server.
    [Visual Basic]
' ReceiveTimeout must be set to a positive value before using the Login method.
Telnet1.ReceiveTimeout = 3000

' Connect and login to the Telnet server
Telnet1.Login("myserver", "myusername", "mypassword", "$")
[C#]
// ReceiveTimeout must be set to a positive value before using the Login method.
telnet1.ReceiveTimeout = 3000;

// Connect and login to the Telnet server
telnet1.Login("myserver", "myusername", "mypassword", "$");
  5. After login succeeds, option negotiation will automatically occur. Check the Option.State properties of the modified Option objects to see if option negotiation occurred as expected.
    [Visual Basic]
' What is the result of option negotiation?
Dim o as Option
For Each o in Telnet1.ClientOptions
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
Next

For Each o in Telnet1.ServerOptions
    Debug.WriteLine("Code: " + o.Code)
    Debug.WriteLine("State: " + o.State)
Next
[C#]
// What is the result of option negotiation?
foreach(Option o in telnet1.ClientOptions)
{
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
}
foreach(Option o in telnet1.ClientOptions)
{
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
}
  6. Compile and run the application.

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Rlogin Component Basic Usage

The RLOGIN protocol is very similar to TELNET except simpler, as there is no option negotiation. In addition, the .rhosts file is typically configured to provide remote access without an interactive login. If the .rhosts file is not configured for the remote access by a client, then a prompt similar to TELNET is used to authenticate the client. This example demonstrates a basic RLOGIN usage scenario.

To quickly get started using the Rlogin component.

  1. Create a new Windows application in Visual Studio .NET.
  2. Add the Rlogin component to the new form. For instructions on how to do this see Creating An Instance Of A Component Using Visual Studio .NET
  3. Add a button to the form.
  4. Be sure you are added to the .rhosts file of the machine you are logging into. Otherwise, you may be prompted for a username/password.
  5. Login to the remote machine.

    [Visual Basic, C#]

    [C#]
// Login
rlogin1.Login("myserver", "myname");
[Visual Basic]
' Login
rlogin1.Login("myserver", "myname");

  6. Once login has completed successfully, receive the greeting from the server. Use the Rlogin.WaitFor method to keep receiving data until the command prompt is found.

    [Visual Basic, C#]

    [C#]
// wait for the command prompt, be sure to set ReceiveTimeout to nonzero number
rlogin1.ReceiveTimeout = 5000;
string s = rlogin1.WaitFor("~>");
Debug.WriteLine(s);
[Visual Basic]
' wait for the command prompt, be sure to set ReceiveTimeout to nonzero number
Rlogin1.ReceiveTimeout = 5000
Dim s As String = Rlogin1.WaitFor("~>")
Debug.WriteLine(s)

  7. Now send a command.

    [Visual Basic, C#]

    [C#]
// Send PWD command
rlogin1.Send("pwd\r\n");
[Visual Basic]
' Send PWD command
Rlogin1.Send("pwd" + vbCrLf)
  8. Receive and display the response.

    [Visual Basic, C#]

    [C#]
Segment seg = rlogin1.Receive();
Debug.WriteLine("Current dir: " + seg.ToString());
[Visual Basic]
Dim Seg As Segment = Rlogin1.Receive()
Debug.WriteLine("Current dir: " + Seg.ToString())
  9. Close the connection.
    [C#]
rlogin1.Close();
[Visual Basic]
Rlogin1.Close()
  10. Compile and run the application.

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Rexec/Rsh Components Basic Usage

PowerTCP Telnet for .NET

Rexec/Rsh Basic Usage

RSH and REXEC work very similarly in that they are both used to log in to a host (typically to a UNIX host), execute a command, and log out. Operation is very simple, involving only the single method call Execute.

The following example demonstrates the Rexec component. The Rsh component would work similarly except you would need to be added to the host's .rhosts file and you would not need to supply username/password info when calling the Execute method.

To use the Rexec component to execute a command on a remote host.

  1. Create a new Windows application in Visual Studio .NET.
  2. Add the Rexec component to the new form. For instructions on how to do this see Creating An Instance Of A Component Using Visual Studio .NET .
  3. Add a button to the form.
  4. Within the button's onClick event, place the following code which executes a PWD (print working directory) command and displays the response from the server. If this fails, an Exception will be thrown.

    [Visual Basic, C#]

    [C#]
// Execute a command
Segment seg  = rexec1.Execute("myserver", "myusername", "mypass", "pwd");

// Display the response from the server
Debug.WriteLine("Current dir: " + seg.ToString());
[Visual Basic]
' Execute a command
Dim seg As Segment = Rexec1.Execute("myserver", "myusername", "mypass", "pwd")

' Display the response from the server
Debug.WriteLine("Current dir: " + seg.ToString())
  5. Compile and run the application.

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Using Asynchronous Methods

Asynchronous operations are useful because they occur without waiting for the action to complete before executing the next line of code. Such a technique is useful when an operation is time consuming and other code needs to execute without waiting for the operation to complete or in an application where a receive must be pending to receive data. The following example demonstrates connecting asynchronously using the Telnet.BeginReceive method. Asynchronous use works similarly for other BeginXXX methods.

To receive data asynchronously.

  1. Add a button to the form.
  2. In this example, the Telnet.BeginReceive method will be used. The EndReceive event will be raised when this operation has completed. "Wire-up" the EndReceive event. For more information on how to do this, see "Using Events In PowerTCP".
  3. Connect to a server using the login method.

    [Visual Basic, C#]

    [C#]
// ReceiveTimeout must be set to a positive value before using the Login method.
telnet1.ReceiveTimeout = 3000;

// Connect and login to the TELNET server
telnet1.Login("myserver", "myusername", "mypassword", "$");
[Visual Basic]
' ReceiveTimeout must be set to a positive value before using the Login method.
Telnet1.ReceiveTimeout = 3000

' Connect and login to the TELNET server
Telnet1.Login("myserver", "myusername", "mypassword", "$")
  4. After connecting, use the BeginReceive method to post a receive operation.

    [Visual Basic, C#]

    [C#]

' Begin an asynchronous receive operation. When data is received, the EndReceive event will be raised.
byte[] buffer = new byte[telnet1.ReceiveBufferSize];
telnet1.BeginReceive(buffer);
[Visual Basic]

' Begin an asynchronous receive operation. When data is received, the EndReceive event will be raised.
Dim buffer As New Byte(Telnet1.RecieveBufferSize)
Telnet1.BeginReceive(buffer)
  5. When data is received, the EndReceive event is raised. Typically, the the Telnet component will need to be "re-armed" with a new BeginReceive operation within this event. As an alternative, you can use the AutoReceive property to always have a pending BeginReceive operation. Using this methodology, you would never have to call a method to receive data within your code, the EndReceive event would simply be raised whenever data is received.

    [Visual Basic, C#]

    [C#]
private void telnet1_EndReceive(object sender, Dart.PowerTCP.Telnet.SegmentEventArgs e)
{
  // Check for any exceptions which may have occurred during the connect operation.
  if(e.Exception == null)
  {
     // Do something with received data
     Debug.WriteLine("Data: " + e.Segment.ToString());

     // Begin a new Receive
     telnet1.BeginReceive(buffer);
  }
}
[Visual Basic]
Private Sub Telnet1_EndReceive(ByVal sender As Object, ByVal e As Dart.PowerTCP.Telnet.SegmentEventArgs) Handles Telnet1.EndReceive
   ' Check for any exceptions which may have occurred during the connect operation.
   If e.Exception Is Nothing Then
      ' Do something with received data
      Debug.WriteLine("Data: " + e.Segment.ToString())

      ' Begin a new Receive
      Telnet1.BeginReceive(buffer)
   End If
End Sub
  6. Compile and run the application.

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Using Events In PowerTCP

There are three kinds of events you may encounter when using PowerTCP Telnet for .NET:

  1. Process Completed Events
  2. Property Changed Events
  3. Reporting Events

Process Completed Events are used to notify the application that a process has completed. All of the EndXXX events (such as EndSend event) are completion events. For example, when sending TELNET data asynchronously using the Telnet.BeginSend method, the EndSend event is raised to notify the application that the data has been sent, either successfully or unsuccessfully. An EventArgs object is made available to your event handler containing information about the operation.

Property Changed Events are used to notify the application that the value of a property has changed. The ConnectedChanged event is an example of a property changed event. For example, every time the Connected property changes, this event is raised.

Reporting Events are used to report while an operation is occurring. The Trace event is an example of a reporting event. For example, when data is sent or received the Trace event is raised to notify the application of the data sent/received. A SegmentEventArgs object will be made available to this event containing information about the operation.

This topic (and related subtopics) describe usage of these events.

In This Section

Using Events Within The Visual Studio .NET Environment
Describes how to use PowerTCP events within the Visual Studio .NET environment.
Using Events When A Component Is Used As A Reference
Describes the extra steps required to use events when using a PowerTCP component as a reference.
Using EndXXX Events
Describes how to use the EndXXX events that are raised upon the completion of a method.

Related Sections

Getting Started
Provides an overview of PowerTCP Telnet for .NET and discusses such topics as distribution, licensing, and support.
Using PowerTCP Within Visual Studio .NET
Demonstrates how to create a project and add a PowerTCP component.
Using The Telnet And Remote Access Components
Demonstrates how to use the Telnet, Rlogin, Rexec, and Rsh components.
Reference
Provides a language/syntax reference for PowerTCP Telnet for .NET.
Samples
Describes the samples that are installed with PowerTCP Telnet for .NET.

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Using Events Within The Visual Studio .NET Environment

The Visual Studio .NET environment has built-in support for "wiring-up" and using component events, making their use simple.

To "wire-up" an event using the Visual Studio environment using VB.NET, use the following steps. (Steps for C# follow).

  1. Start a new VB.NET project and add a component to the form (see Creating An Instance Of A Component Using Visual Studio .NET for information on how to do this). For this example, the Telnet component is used.
  2. Navigate to View, and then select Code to switch to code view.
  3. From the "drop-down" boxes at the top of the Code Window, select the instance of the Telnet component from the box on the left, and then the name of the event you would like to "wire-up" from the box on the right (see screenshot below).

  4. After doing this, the Visual Studio .NET environment will transparently create the necessary code to "wire-up" the event. The code should look similiar to the following (using the EndSend event as an example).
    5. Private Sub Telnet1_EndSend(ByVal sender As Object, ByVal e As Dart.PowerTCP.Telnet.SegmentEventArgs) Handles Telnet1.EndSend
   ' Write event handling code here.
End Sub
  5. Now you can use the Telnet.BeginSend method and handle the completion of the method in the EndSend event.

To "wire-up" an event using the Visual Studio environment using C#, use the following steps.

  1. Start a new C# project and add the Telnet component to the form (see Using A Component Within Visual Studio .NET for information on how to do this).
  2. Click the component icon, created on the panel underneath the form.
  3. On the Properties Window click the "lightning bolt" icon to display all events for the Telnet component.
  4. Double-click the event you wish to "wire-up" (see screenshot below).

  5. After doing this, the Visual Studio .NET environment will automatically create the necessary code to "wire-up" the event. The code should look similiar to the following (using the EndSend event as an example).
    6. private void telnet1_EndSend(object sender, Dart.PowerTCP.Telnet.SegmentEventArgs e)
{
   // Write event handling code here.
}
  6. Now you can use the Telnet.BeginSend method and handle the completion of the method in the EndSend event.

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Using Events When A Component Is Used As A Reference

PowerTCP Telnet for .NET

Using Events When Using A Component As A Reference

If you are using the a PowerTCP component as a class (instead of adding it to the project as a component), and would like to use events, you must "wire-up" the event yourself. This topic addresses how to do this using either VB.NET or C#. Note: You do NOT need to "wire-up" the events yourself if you are dragging an instance of a PowerTCP component onto the form while using Visual Studio .NET. In this case all event subscription will be handled by the environment.

To use events when using a PowerTCP component as a class and creating a VB.NET Windows Application, use the following steps (steps for C# below).

  1. Start a new VB.NET project and add a PowerTCP component as a reference (see Adding A Component As A Reference Within Visual Studio .NET for information of how to do this). In this example, the Telnet component is used.
  2. Navigate to the View menu and then select Code to switch to code view.
  3. Create an instance of the Telnet class. Be sure to use the WithEvents keyword such as in the following:
    4. Private WithEvents Telnet1 As New Dart.PowerTCP.Telnet.Telnet()
  4. You must create a method that implements the appropriate delegate. The first step is to determine which event you would like to "wire-up". For the purposes of this walkthrough, the EndSend event will be used, although other events would work in a similar manner.
  5. Navigate to the EndSend event in the Reference section.
  6. The syntax definition for the appropriate language specifies which delegate is implemented by the event. For example the VB.NET syntax for the EndSend event is:
    7. public Event EndSend As SegmentEventHandler
    In other words, to "wire-up" the Telnet.EndSend event, you must first create a method that implements the SegmentEventHandler delegate.
  7. Navigate to the reference listing for the SegmentEventHandler delegate. This listing will tell you what your event-handler method should look like. According to the SegmentEventHandler delegate, your method must accept two arguments (an object and an SegmentEventArgs object) and return nothing, so create a method that does this. This method should look similar to the following:
    8. Private Sub MyEndSendHandler(ByVal sender As Object, ByVal e As Dart.PowerTCP.Telnet.SegmentEventArgs)
   ' Write code to handle the event here.
End Sub
  8. Finally, the event handler must "subscribe" to the event. In VB.NET, this can simply be done by using the "Handles " keyword next to the event handler as such:
    9. Private Sub MyEndSendHandler(ByVal sender As Object, ByVal e As Dart.PowerTCP.Telnet.SegmentEventArgs) Handles Telnet1.EndSend
   ' Write code to handle the event here.
End Sub
  9. Alternatively, you can use the AddHandles keyword to "subscribe" an event handler to an event. This is done like so:
    10. AddHandler Telnet.Trace, AddressOf Me.MyTraceHandler
  10. Now the Telnet.BeginSend method can be used, and the EndSend event will be raised upon the completion of this method.

To use events when using a PowerTCP component as a reference and creating a C# Windows Application, use the following steps.

  1. Start a new C# project and add a PowerTCP component as a reference (see Adding A Component As A Reference Within Visual Studio .NET for information of how to do this. In this example, the Telnet component is used.
  2. Navigate to the View menu, and then select Code to switch to code view.
  3. Create an instance of the Telnet class such as:
    4. private Dart.PowerTCP.Telnet.Telnet telnet1 = new Dart.PowerTCP.Telnet.Telnet();
  4. Now you must create a method that implements the appropriate delegate. The first step is to determine which event you would like to "wire-up". For the purposes of this walkthrough, the EndSend event will be used, although other events would work in a similar manner.
  5. Navigate to the EndSend event in the Reference section.
  6. The syntax definition for the appropriate language specifies which delegate is implemented by the event. For example the C# syntax for the EndSend event is:
    7. public event SegmentEventHandler EndSend;
    In other words, to "wire-up" the Telnet.EndSend event, you must first create a method that implements the SegmentEventHandler delegate.
  7. Navigate to the reference listing for the SegmentEventHandler delegate. This listing will tell you what your event-handler method should look like. According to the SegmentEventHandler delegate, your method must accept two arguments (an object and a SegmentEventArgs) and return void, so create a method that does this. This method should look similiar to the following:
    8. private void MyEndSend(object sender, Dart.PowerTCP.Telnet.SegmentEventArgs e)
{
   // Write code to handle the event here.
}
  8. Finally, the event handler must "subscribe" to the event. In C#, this can be done as such (put this code in your form initialization):
    9. telnet1.EndSend += new Dart.PowerTCP.Telnet.SegmentEventHandler(this.MyEndSend);
  9. Now the BeginSend method can be used, and the EndSend event will be raised upon the completion of this method.

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Using EndXXX Events

An EndXXX event is a generic term to describe any event used by PowerTCP Telnet for .NET that begins with the word "End". These events are reserved to notify the application of a process being completed. In addition, all EndXXX events are raised by the completion of a corresponding BeginXXX method. The EndXXX events used by PowerTCP Telnet for .NET components are as follows:

Event | Raised By | Purpose
Telnet.EndConnect Event | Use of the Telnet.BeginConnect method | Notifies the application that the Telnet component is connected.
Telnet.EndReceive event | Use of the Telnet.BeginReceive method | Notifies the application that data has been received.
Telnet.EndSend event | Use of the Telnet.BeginSend method | Notifies the application that data has been asynchronously sent.

Comparison With Other Techniques:

PowerTCP products employ a unique technique for handling asynchronous completion notification:

  1. As compared to using the delegate technique, by using Events for completion notification, PowerTCP gives developers strong environment support for adding event handlers. For example (using the Tcp component as an example):
  2. Before raising the completion event, the component calls the (internal) delegate's EndReceive method, capturing any Exceptions thrown during asynchronous execution. Using this technique, PowerTCP ensures that all asynchronous calls are properly terminated, and consequently eliminates one programming step that would normally have to be accomplished by our users.
  3. When any BeginXXX method is used, PowerTCP checks for the appropriate event handler and throws an InvalidOperationException if none is found. This action ensures proper usage.

We believe that this approach has made asynchronous communications programming as easy as it gets, providing our users with superior value.

Special Notes About EndXXX Events:

Be sure to check the e.Exception property for exceptions that occurred during the asynchronous method call. If the operation failed to complete, the presence of an Exception may be your only indication that the operation failed.

It is a very good programming practice to surround your event code with a try/catch block. If you do not do so and generate an exception within your code, a default exception handler will display your exception to the user of your application using a MessageBox. If an exception was thrown during the asynchronous operation and you access one of the properties of the EventArgs, the Exception will be thrown.

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Reference

This section contains reference documentation for all of the classes that comprise PowerTCP Telnet for .NET. This section is intended solely for use as a class reference guide for use while building an application. It is NOT intended to give a "walkthrough" type description of usage. For a description of this type, see the higher-level topics.

In This Section

Dart.PowerTCP.Telnet Namespace
Contains classes that support and enable the creation of TELNET, RLOGIN, RSH, and REXEC applications.

Related Sections

Getting Started
Provides an overview of PowerTCP Telnet for .NET and discusses such topics as distribution, licensing, and support.
Using PowerTCP Within Visual Studio .NET
Demonstrates how to create a project and add a PowerTCP component.
Using The Telnet And Remote Access Components
Demonstrates how to use the Telnet, Rlogin, Rexec, and Rsh components.
Using Events In PowerTCP
Discusses the methodology behind the event implementation for PowerTCP Telnet for .NET, including step-by-step tutorials for implementing your own events.
Samples
Describes the samples that are installed with PowerTCP Telnet for .NET.

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Dart.PowerTCP.Telnet

PowerTCP Telnet for .NET

Dart.PowerTCP.Telnet Namespace

Classes

Class | Description
CommandEventArgs | Provides data for the Telnet.CommandReceived event.
EnhancedStream | Adds new methods on top of the Stream interface for type conversion, stream copying, and saving.
ExceptionEventArgs | Provides data for asynchronous event handlers.
InvalidParameterTypeException | Thrown whenever a method is called with an invalid parameter.
Option | Encapsulates a Telnet option.
OptionCollection | A collection of Option objects.
OptionEventArgs | Provides data for the Telnet.ClientOptionChanged and Telnet.ServerOptionChanged events
PipeStream | Represents a stream that wraps an internal stream.
ProtocolException | Used to throw protocol exceptions for upper-layer protocols like FTP, SMTP and POP3.
Proxy | Provides an easy way to manage communication with proxy servers
Rexec | The Rexec component enables use of the remote execution protocol within any .NET application.
Rlogin | The Rlogin component enables use of the remote login protocol within any .NET application.
Rsh | The Rsh component enables use of the remote shell protocol within any .NET application.
Segment | Provides a reference to a data segment where data is sent or received over a TCP stream.
SegmentedStream | Used to provide advanced reading/writing capabilites to Stream-based objects.
SegmentEventArgs | Provides data for any event where data is sent or received.
Tcp | The Tcp component provides comprehensive Transmission Control Protocol support.
TcpStream | TcpStream implements sending and receiving of data through network sockets.
Telnet | Integrates Telnet communications into any .NET application.
TelnetStream | Performs Telnet-specific formatting of data passing through the stream.

Delegates

Delegate | Description
CommandEventHandler | Represents the method (event handler) that is raised when a command is received from the server.
ConnectEventHandler | Represents the method (event handler) that is raised when the BeginConnect operation completes.
OptionEventHandler | Represents the method (event handler) that is raised when an option value is changed.
SegmentEventHandler | Represents the method (event handler) that is raised when data is received or sent.

Enumerations

Enumeration | Description
Command | Enumerates the TELNET protocol commands that can be sent.
OptionCode | Enumerates the supported options.
OptionState | Enumerates the current state of an Option object.
ProxyType | Enumerates the supported proxy types.


Command Enumeration

Enumerates the TELNET protocol commands that can be sent.

[Visual Basic]
Public Enum Command
[C#]
public enum Command

Remarks

The TELNET protocol uses "in-band" signaling to send commands. This means a special byte, the Interpret As Command (Iac) byte, is sent to let the receiver know to interpret the next byte as a command. TELNET commands can fall under several categories. Some commands are used solely during option negotiation (Do, Dont, Will, Wont) to help establish options that both the client and server will use. Other commands represent control functions (Ayt, Brk, Nop, etc) used to emit a particular response from the server.

Members

Member Name | Description
SE | 240 Marks the end of subnegotiation parameters
Nop | 241 No operation
DM | 242 Data stream portion of a Synch. If the sender is sending Urgent data, this notifies the recipeint to resume normal processing.
Brk | 243 Break. Indicates the "Break" key on the recipient host was hit.
IP | 244 Interrupt process. Invokes a function on the recipient to suspend, interrupt, abort, or terminate a user process.
AO | 245 Abort output. Invokes a function on the recipient to stop sending output data while continuing the current process.
Ayt | 246 Are you there. Invokes a function on the recipient to provide printable evidence that it is still up and running.
EC | 247 Erase character. Invokes a function on the recipient to "delete" the preceding undeleted character from the incoming stream of data.
EL | 248 Erase line. Invokes a function on the recipient to "delete" the preceding undeleted line from the incoming stream of data.
GA | 249 Go ahead. Typically is suppressed.
SB | 250 Used during option negotiation to establish/provide data for a suboption. Indicates what follows is subnegotiation of the indicated option.
Will | 251 Used during option negotiation. Indicates the desire to begin performing, or confirmation that you are now performing, the indicated option
Wont | 252 Used during option negotiation. Indicates the refusal to perform, or continue performing, the indicated option
Do | 253 Used during option negotiation. Indicates the request that the other party perform, or confirmation that you are expecting the other party to perfrom, the indicated option
Dont | 254 Used during option negotiation. Indicates the demand that the other party stop performing, or confirmation that you are no longer expecting the other party to perform, the indicated option
Iac | 255 Interpret As Command byte (255). Tells the recipient to interprt the next byte as a command.

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

Dart.PowerTCP.Telnet Namespace


CommandEventArgs Class

Provides data for the Telnet.CommandReceived event.

For a list of all members of this type, see CommandEventArgs Members.

System.Object
EventArgs
CommandEventArgs

[Visual Basic]
Public Class CommandEventArgs
Inherits EventArgs
[C#]
public class CommandEventArgs : EventArgs

Remarks

An instance of the CommandEventArgs type is a parameter of the Telnet.CommandReceived event, encapsulating the command for which the event was raised.

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

CommandEventArgs Members | Dart.PowerTCP.Telnet Namespace


CommandEventArgs Members

CommandEventArgs overview

Public Instance Properties

Command | Represents the command sent by the remote host.
OptionCode | Represents the option to which the command pertains.
SubOption | Contains the suboption data.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

See Also

CommandEventArgs Class | Dart.PowerTCP.Telnet Namespace


CommandEventArgs Properties

The properties of the CommandEventArgs class are listed below. For a complete list of CommandEventArgs class members, see the CommandEventArgs Members topic.

Public Instance Properties

Command | Represents the command sent by the remote host.
OptionCode | Represents the option to which the command pertains.
SubOption | Contains the suboption data.

See Also

CommandEventArgs Class | Dart.PowerTCP.Telnet Namespace


CommandEventArgs.Command Property

Represents the command sent by the remote host.

[Visual Basic]
Public ReadOnly Property Command As Command
[C#]
public Command Command {get;}

Property Value

A Command value specifying the command sent by the remote host.

Remarks

This property represents the command sent by the remote host. For example, if the command from the server was a Do ECHO command, asking the client to enable echoing, this property will return Command.Do.

See Also

CommandEventArgs Class | Dart.PowerTCP.Telnet Namespace


CommandEventArgs.OptionCode Property

Represents the option to which the command pertains.

[Visual Basic]
Public ReadOnly Property OptionCode As OptionCode
[C#]
public OptionCode OptionCode {get;}

Property Value

An OptionCode value specifying the option.

Remarks

This property represents the option to which the command pertains. For example, if the command from the server was a Do ECHO command, asking the client to enable echoing, this property would return OptionCode.Echo.

See Also

CommandEventArgs Class | Dart.PowerTCP.Telnet Namespace


CommandEventArgs.SubOption Property

Contains the suboption data.

[Visual Basic]
Public ReadOnly Property SubOption As Byte()
[C#]
public byte[] SubOption {get;}

Property Value

A byte array containing suboption data.

Remarks

Some options require suboption data. The CommandEventArgs.SubOption property contains this suboption data. Refer to the RFC that documents the specific option for the exact format of the suboption data within the byte array as suboption usage is specific to a limited number of options.

See Also

CommandEventArgs Class | Dart.PowerTCP.Telnet Namespace


CommandEventHandler Delegate

Represents the method (event handler) that is raised when a command is received from the server.

[Visual Basic]
Public Delegate Sub CommandEventHandler( _
ByVal sender As Object, _
ByVal e As CommandEventArgs _
)
[C#]
public delegate void CommandEventHandler(
object sender,
CommandEventArgs e
);

Remarks

As Microsoft describes in their MSDN documentation, the event model in the .NET Framework is based on having an event delegate that connects an event with its handler. To raise an event, two elements are needed:

  • A class that holds the event data. This class must derive from the base class EventArgs.
  • A delegate that points to a method that provides the response to the event.

When the Telnet.CommandReceived event is raised, the class that holds the event data is the CommandEventArgs class. A method must be created with the same signature as the delegate. In this example that would mean a method would have to be defined to accept two arguments (an object and a CommandEventArgs) and return void. Once this has been done, the delegate must be "connected" to the handling event. This is done by adding an instance of the delegate to the event.

For more information about event handler delegates, see the Using Events in PowerTCP topic.

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

Dart.PowerTCP.Telnet Namespace


ConnectEventHandler Delegate

Represents the method (event handler) that is raised when the BeginConnect operation completes.

[Visual Basic]
Public Delegate Sub ConnectEventHandler( _
ByVal sender As Object, _
ByVal e As ExceptionEventArgs _
)
[C#]
public delegate void ConnectEventHandler(
object sender,
ExceptionEventArgs e
);

Parameters

sender
The source of the event.
e
A ExceptionEventArgs object that contains the event data.

Remarks

As Microsoft describes in their MSDN documentation, the event model in the .NET Framework is based on having an event delegate that connects an event with its handler. To raise an event, two elements are needed:

  • A class that holds the event data. This class must derive from the base class EventArgs.
  • A delegate that points to a method that provides the response to the event.
When using the BeginConnect method, the class that holds the event data is the ExceptionEventArgs class. A method must be created with the same signature as the delegate. In this example that would mean a method would have to be defined to accept two arguments (an object and a ExceptionEventArgs) and return void. Once this has been done, the delegate must be "connected" to the handling event. This is done by adding an instance of the delegate to the event.

For more information about event handler delegates, see the Using Events In PowerTCP topic.

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

Dart.PowerTCP.Telnet Namespace


EnhancedStream Class

Adds new methods on top of the Stream interface for type conversion, stream copying, and saving.

For a list of all members of this type, see EnhancedStream Members.

System.Object
MarshalByRefObject
Stream
EnhancedStream

[Visual Basic]
MustInherit Public Class EnhancedStream
Inherits Stream
[C#]
public abstract class EnhancedStream : Stream

Remarks

Inherit from this abstract class to create a Stream class with enhanced methods. For example, EnhancedStream.Save allows you to save Stream data directly to a file. EnhancedStream.ToString returns a string representation of the data contained within the Stream.

All PowerTCP Stream classes (such as SegmentedStream, PipeStream) inherit from this class to provide the enhanced capabilities described above to these classes.

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

EnhancedStream Members | Dart.PowerTCP.Telnet Namespace


EnhancedStream Members

EnhancedStream overview

Public Instance Properties

CanRead | Gets a value indicating whether the current stream supports reading.
CanSeek | Gets a value indicating whether the current stream supports seeking.
CanWrite | Gets a value indicating whether the current stream supports writing.
Charset | Gets and sets the character set used for string/byte array conversions.
Encoding | Gets or sets the type of encoding to use.
Length | The length of data available on the stream. This method always throws a NotSupportedException.
Position | Gets or sets the position in the stream. This method always throws a NotSupportedException.

Public Instance Methods

BeginRead (inherited from Stream) | Begins an asynchronous read operation.
BeginWrite (inherited from Stream) | Begins an asynchronous write operation.
Close (inherited from Stream) | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose | Overloaded. Releases all resources associated with the object.
EndRead (inherited from Stream) | Waits for the pending asynchronous read to complete.
EndWrite (inherited from Stream) | Ends an asynchronous write operation.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Flush | Default implementation is no-op. May be overriden by derived classes
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Read (inherited from Stream) | Overloaded. When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
Read | Overloaded. Reads at least one byte of data from the Stream and copies it into the provided buffer.
ReadByte (inherited from Stream) | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
Save | Overloaded. Saves the data in the stream to the file specified by fileName.
Seek | Sets the position within the current Stream to the specified value. Always throws a NotSupportedException.
SetLength | Sets the length of the current Stream to the specified value. Always throws a NotSupportedException.
ToArray | Returns the byte array representation of the Stream data.
ToString | Returns the string representation of the Stream data.
Write (inherited from Stream) | Overloaded. When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
Write | Overloaded. Writes a sequence of bytes to the Stream and returns when the operation is complete.
WriteByte (inherited from Stream) | Writes a byte to the current position in the stream and advances the position within the stream by one byte.
WriteTo | Overloaded. Writes all of the data contained in this Stream to a destination Stream.

Explicit Interface Implementations

IDisposable.Dispose (inherited from Stream)

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace


EnhancedStream Properties

The properties of the EnhancedStream class are listed below. For a complete list of EnhancedStream class members, see the EnhancedStream Members topic.

Public Instance Properties

CanRead | Gets a value indicating whether the current stream supports reading.
CanSeek | Gets a value indicating whether the current stream supports seeking.
CanWrite | Gets a value indicating whether the current stream supports writing.
Charset | Gets and sets the character set used for string/byte array conversions.
Encoding | Gets or sets the type of encoding to use.
Length | The length of data available on the stream. This method always throws a NotSupportedException.
Position | Gets or sets the position in the stream. This method always throws a NotSupportedException.

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace


EnhancedStream.CanRead Property

Gets a value indicating whether the current stream supports reading.

[Visual Basic]
Overrides Public ReadOnly Property CanRead As Boolean
[C#]
public override bool CanRead {get;}

Remarks

This property returns true unless overridden in a derived class.

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace


EnhancedStream.CanSeek Property

Gets a value indicating whether the current stream supports seeking.

[Visual Basic]
Overrides Public ReadOnly Property CanSeek As Boolean
[C#]
public override bool CanSeek {get;}

Remarks

This property always returns false.

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace


EnhancedStream.CanWrite Property

Gets a value indicating whether the current stream supports writing.

[Visual Basic]
Overrides Public ReadOnly Property CanWrite As Boolean
[C#]
public override bool CanWrite {get;}

Remarks

This property returns true unless overridden in a derived class.

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace


EnhancedStream.Charset Property

Gets and sets the character set used for string/byte array conversions.

[Visual Basic]
Public Property Charset As String
[C#]
public string Charset {get; set;}

Property Value

A string representing the character set used.

Remarks

This value defaults to the language used on the runtime machine (accessable through System.Text.Encoding.Default.BodyName). Set this property to the desired character set string to override this behavior. An example charset for Kanji is "ISO-2022-JP", while standard ASCII is: "ISO-8859-1".

When communicating with clients from other countries set this property based on the standard string defined for the language intended. This enables the International client to be able to properly decode the data.

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace


EnhancedStream.Length Property

The length of data available on the stream. This method always throws a NotSupportedException.

[Visual Basic]
Overrides Public ReadOnly Property Length As Long
[C#]
public override long Length {get;}

Exceptions

Exception Type | Condition
NotSupportedException | Always throws this exception.

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace


EnhancedStream.Position Property

Gets or sets the position in the stream. This method always throws a NotSupportedException.

[Visual Basic]
Overrides Public Property Position As Long
[C#]
public override long Position {get; set;}

Exceptions

Exception Type | Condition
NotSupportedException | Always throws this exception.

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace


EnhancedStream Methods

The methods of the EnhancedStream class are listed below. For a complete list of EnhancedStream class members, see the EnhancedStream Members topic.

Public Instance Methods

BeginRead (inherited from Stream) | Begins an asynchronous read operation.
BeginWrite (inherited from Stream) | Begins an asynchronous write operation.
Close (inherited from Stream) | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose | Overloaded. Releases all resources associated with the object.
EndRead (inherited from Stream) | Waits for the pending asynchronous read to complete.
EndWrite (inherited from Stream) | Ends an asynchronous write operation.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Flush | Default implementation is no-op. May be overriden by derived classes
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Read (inherited from Stream) | Overloaded. When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
Read | Overloaded. Reads at least one byte of data from the Stream and copies it into the provided buffer.
ReadByte (inherited from Stream) | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
Save | Overloaded. Saves the data in the stream to the file specified by fileName.
Seek | Sets the position within the current Stream to the specified value. Always throws a NotSupportedException.
SetLength | Sets the length of the current Stream to the specified value. Always throws a NotSupportedException.
ToArray | Returns the byte array representation of the Stream data.
ToString | Returns the string representation of the Stream data.
Write (inherited from Stream) | Overloaded. When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
Write | Overloaded. Writes a sequence of bytes to the Stream and returns when the operation is complete.
WriteByte (inherited from Stream) | Writes a byte to the current position in the stream and advances the position within the stream by one byte.
WriteTo | Overloaded. Writes all of the data contained in this Stream to a destination Stream.

Explicit Interface Implementations

IDisposable.Dispose (inherited from Stream)

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace


EnhancedStream.Flush Method

Default implementation is no-op. May be overriden by derived classes

[Visual Basic]
Overrides Public Sub Flush()
[C#]
public override void Flush();

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace


Read Method

PowerTCP Telnet for .NET

EnhancedStream.Read Method

Reads at least one byte of data from the Stream and copies it into the provided buffer.

Overload List

Reads at least one byte of data from the Stream and copies it into the provided buffer.

public int Read(byte[]);

Inherited from Stream.

public abstract int Read(byte[],int,int);

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace


EnhancedStream.Read Method (Byte[])

Reads at least one byte of data from the Stream and copies it into the provided buffer.

[Visual Basic]
Overloads Public Function Read( _
ByVal buffer As Byte() _
) As Integer
[C#]
public int Read(
byte[] buffer
);

Parameters

buffer
The storage location for the received data.

Return Value

The total number of bytes read into the buffer.

Remarks

This is a convenience method for all derived classes, calling Read(buffer,0, buffer.Length) on the stream.

Exceptions

Exception Type | Condition
IOException | Thrown when the Stream is not readable.
ArgumentNullException | Thrown when the buffer or callback is null.

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace | EnhancedStream.Read Overload List


Save Method

PowerTCP Telnet for .NET

EnhancedStream.Save Method

Saves the data in the stream to the file specified by fileName.

Overload List

Saves the data in the stream to the file specified by fileName.

public virtual string Save(string);

Saves the data in the stream to the file specified by fileName.

public virtual string Save(string,bool);

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace


EnhancedStream.Save Method (String)

Saves the data in the stream to the file specified by fileName.

[Visual Basic]
Overridable Overloads Public Function Save( _
ByVal fileName As String _
) As String
[C#]
public virtual string Save(
string fileName
);

Parameters

fileName
The desired name of the destination file.

Return Value

A string containing the name of the file the data was written to.

Remarks

This method saves all of the data in the stream to the file specified by fileName. This method will always create a new file, creating a unique filename if the file already exists.

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace | EnhancedStream.Save Overload List


EnhancedStream.Save Method (String, Boolean)

Saves the data in the stream to the file specified by fileName.

[Visual Basic]
Overridable Overloads Public Function Save( _
ByVal fileName As String, _
ByVal overwrite As Boolean _
) As String
[C#]
public virtual string Save(
string fileName,
bool overwrite
);

Parameters

fileName
The desired name of the destination file.
overwrite
Controls whether or not to overwrite existing files.

Return Value

A string containing the name of the file the data was written to.

Remarks

This method saves all of the data in the stream to the file specified by fileName. If overwrite is true, this method will create a new file if the specified file does not exist and will overwrite the specified file if it does exist. If overwrite is false, this method will always create a new file, creating a unique filename if the file already exists.

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace | EnhancedStream.Save Overload List


EnhancedStream.Seek Method

Sets the position within the current Stream to the specified value. Always throws a NotSupportedException.

[Visual Basic]
Overrides Public Function Seek( _
ByVal offset As Long, _
ByVal origin As SeekOrigin _
) As Long
[C#]
public override long Seek(
long offset,
SeekOrigin origin
);

Parameters

offset
The new position within the stream
origin
A value of type SeekOrigin, which acts as the seek reference point.

Remarks

This method is not supported, and always throws a NotSupportedException.

Exceptions

Exception Type | Condition
NotSupportedException | Always thrown by this method.

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace


EnhancedStream.SetLength Method

Sets the length of the current Stream to the specified value. Always throws a NotSupportedException.

[Visual Basic]
Overrides Public Sub SetLength( _
ByVal value As Long _
)
[C#]
public override void SetLength(
long value
);

Parameters

value
The value at which to set the length.

Remarks

This method is not supported, and always throws a NotSupportedException.

Exceptions

Exception Type | Condition
NotSupportedException | Always thrown by this method.

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace


EnhancedStream.ToArray Method

Returns the byte array representation of the Stream data.

[Visual Basic]
Overridable Public Function ToArray() As Byte()
[C#]
public virtual byte[] ToArray();

Return Value

The byte array representation of the Stream data.

Remarks

Use this method to easily return the data in the stream as a byte array. Position should be reset after calling this method.

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace


EnhancedStream.ToString Method

Returns the string representation of the Stream data.

[Visual Basic]
Overrides Public Function ToString() As String
[C#]
public override string ToString();

Return Value

The string representation of the Stream data.

Remarks

This method returns the string representation the data contained in the stream, based on the EnhancedStream.Charset.

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace


Write Method

PowerTCP Telnet for .NET

EnhancedStream.Write Method

Writes a sequence of bytes to the Stream and returns when the operation is complete.

Overload List

Writes a sequence of bytes to the Stream and returns when the operation is complete.

public void Write(byte[]);

Inherited from Stream.

public abstract void Write(byte[],int,int);

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace


EnhancedStream.Write Method (Byte[])

Writes a sequence of bytes to the Stream and returns when the operation is complete.

[Visual Basic]
Overloads Public Sub Write( _
ByVal buffer As Byte() _
)
[C#]
public void Write(
byte[] buffer
);

Parameters

buffer
The source location of the data to write.

Remarks

This method is a convenience overload for all derived classes by writing the entire buffer to the Stream. This method calls Write(buffer, 0, buffer.length).

Exceptions

Exception Type | Condition
IOException | Thrown when the Stream is not writeable.
ArgumentNullException | Thrown when the buffer is null.
ArgumentOutOfRangeException | Thrown when the offset is less than zero or when count is less than or equal to zero.
ArgumentException | Thrown when the (offset + count) > buffer.Length.

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace | EnhancedStream.Write Overload List


WriteTo Method

PowerTCP Telnet for .NET

EnhancedStream.WriteTo Method

Writes all of the data contained in this Stream to a destination Stream.

Overload List

Writes all of the data contained in this Stream to a destination Stream.

public void WriteTo(Stream);

Writes all of the data contained in this Stream to a destination Stream.

public void WriteTo(Stream,bool);

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace


EnhancedStream.WriteTo Method (Stream)

Writes all of the data contained in this Stream to a destination Stream.

[Visual Basic]
Overloads Public Sub WriteTo( _
ByVal destination As Stream _
)
[C#]
public void WriteTo(
Stream destination
);

Parameters

destination
The destination stream.

Remarks

This method essentially "copies" one stream to another by setting the destination Stream position to zero, writing all of the data in the source Stream to the destination, resetting the source Stream back to its original position, and resetting the destination to a position of zero.

Exceptions

Exception Type | Condition
NullReferenceException | destination is null.
IOException | Stream is not readable or writeable.

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace | EnhancedStream.WriteTo Overload List


EnhancedStream.WriteTo Method (Stream, Boolean)

Writes all of the data contained in this Stream to a destination Stream.

[Visual Basic]
Overloads Public Sub WriteTo( _
ByVal destination As Stream, _
ByVal resetPosition As Boolean _
)
[C#]
public void WriteTo(
Stream destination,
bool resetPosition
);

Parameters

destination
The destination stream.
resetPosition
Controls whether or not the positions of the source and destination streams are reset during the "copy" process.

Remarks

If resetPositions is true, this method essentially "copies" one stream to another by setting the destination Stream position to zero, writing all of the data in the source Stream to the destination, resetting the source Stream back to its original position, and resetting the destination to a position of zero.

If resetPositions is false, it copies from the current location of the source Stream to the current location of destination, and positions are not set.

Exceptions

Exception Type | Condition
NullReferenceException | destination is null.
IOException | Stream is not readable or writeable.

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace | EnhancedStream.WriteTo Overload List


ExceptionEventArgs Class

Provides data for asynchronous event handlers.

For a list of all members of this type, see ExceptionEventArgs Members.

System.Object
EventArgs
ExceptionEventArgs

[Visual Basic]
Public Class ExceptionEventArgs
Inherits EventArgs
[C#]
public class ExceptionEventArgs : EventArgs

Remarks

A ExceptionEventArgs object is passed into asynchronous event handlers after an asynchronous operation has completed. If an exception occurred during the asynchronous operation, it is returned in ExceptionEventArgs.Exception.

For more information on implementing and handling events using PowerTCP.NET, see the topic, "Events in PowerTCP".

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

ExceptionEventArgs Members | Dart.PowerTCP.Telnet Namespace


ExceptionEventArgs Members

ExceptionEventArgs overview

Public Instance Constructors

ExceptionEventArgs Constructor Initialize default instance of the ExceptionEventArgs class.

Public Instance Properties

Exception | Gets any exception which occurred during the asynchronous operation.
State | Gets the object that was included as part of the associated method call.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

See Also

ExceptionEventArgs Class | Dart.PowerTCP.Telnet Namespace


ExceptionEventArgs Constructor

Initialize default instance of the ExceptionEventArgs class.

[Visual Basic]
Public Sub New( _
ByVal exception As Exception, _
ByVal state As Object _
)
[C#]
public ExceptionEventArgs(
Exception exception,
object state
);

Parameters

exception
state

See Also

ExceptionEventArgs Class | Dart.PowerTCP.Telnet Namespace


ExceptionEventArgs Properties

The properties of the ExceptionEventArgs class are listed below. For a complete list of ExceptionEventArgs class members, see the ExceptionEventArgs Members topic.

Public Instance Properties

Exception | Gets any exception which occurred during the asynchronous operation.
State | Gets the object that was included as part of the associated method call.

See Also

ExceptionEventArgs Class | Dart.PowerTCP.Telnet Namespace


ExceptionEventArgs.Exception Property

Gets any exception which occurred during the asynchronous operation.

[Visual Basic]
Public ReadOnly Property Exception As Exception
[C#]
public System.Exception Exception {get;}

Property Value

If any exception occurred during the asynchronous operation, this property will contain an Exception object describing the exception.

Remarks

Check this property to tell if an exception occurred during the asynchronous operation. If this property is null, no exception occurred.

The exception property is useful for checking exceptions and handling them appropriately. For example, if a bad command was sent to the server, a ProtocolException may be thrown. You could check this property to see if it was of type ProtocolException, than handle appropriately.

See Also

ExceptionEventArgs Class | Dart.PowerTCP.Telnet Namespace


ExceptionEventArgs.State Property

Gets the object that was included as part of the associated method call.

[Visual Basic]
Public ReadOnly Property State As Object
[C#]
public object State {get;}

Property Value

An object containing data passed into the calling asynchronous method.

Remarks

The EndEventArgs.State property can be used in the calling asynchronous method to make data accessable to the handling event.

This property is useful for making data accessible to the handling event. Since asynchronous methods are "disconnected" (meaning that when one is called, it executes on it's own and returns in the event handler) data that you were using in the code that called the asynchronous method may not be available in the event handler. Simply pass this data in as state when calling the asychronous method (usually a BeginXXX method) and it is available in the event handler. If you do not wish to make an object accessable in the EndXXX event, simple pass in null as state.

See Also

ExceptionEventArgs Class | Dart.PowerTCP.Telnet Namespace


InvalidParameterTypeException Class

Thrown whenever a method is called with an invalid parameter.

For a list of all members of this type, see InvalidParameterTypeException Members.

System.Object
Exception
ApplicationException
InvalidParameterTypeException

[Visual Basic]
Public Class InvalidParameterTypeException
Inherits ApplicationException
[C#]
public class InvalidParameterTypeException : ApplicationException

Remarks

This exception is thrown if a method is called with a parameter of the wrong type. To keep this exception from being thrown read the documentation on the function throwing the exception.

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

InvalidParameterTypeException Members | Dart.PowerTCP.Telnet Namespace


InvalidParameterTypeException Members

InvalidParameterTypeException overview

Public Instance Constructors

InvalidParameterTypeException Overloaded. Initializes a new instance of the InvalidParameterTypeException class.

Public Instance Properties

HelpLink (inherited from Exception) | Gets or sets a link to the help file associated with this exception.
InnerException (inherited from Exception) | Gets the Exception instance that caused the current exception.
Message (inherited from Exception) | Gets a message that describes the current exception.
Source (inherited from Exception) | Gets or sets the name of the application or the object that causes the error.
StackTrace (inherited from Exception) | Gets a string representation of the frames on the call stack at the time the current exception was thrown.
TargetSite (inherited from Exception) | Gets the method that throws the current exception.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetBaseException (inherited from Exception) | When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetObjectData (inherited from Exception) | When overridden in a derived class, sets the SerializationInfo with information about the exception.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Exception) | Creates and returns a string representation of the current exception.

See Also

InvalidParameterTypeException Class | Dart.PowerTCP.Telnet Namespace


InvalidParameterTypeException Constructor

Initializes a new instance of InvalidParameterTypeException.

Overload List

Initializes a new instance of InvalidParameterTypeException.

public InvalidParameterTypeException();

Initializes a new instance of InvalidParameterTypeException.

public InvalidParameterTypeException(string);

Initializes a new instance of InvalidParameterTypeException.

public InvalidParameterTypeException(string,Exception);

Initializes a new instance of the InvalidParameterException class.

public InvalidParameterTypeException(string,int);

See Also

InvalidParameterTypeException Class | Dart.PowerTCP.Telnet Namespace


InvalidParameterTypeException Constructor ()

Initializes a new instance of InvalidParameterTypeException.

[Visual Basic]
Overloads Public Sub New()
[C#]
public InvalidParameterTypeException();

See Also

InvalidParameterTypeException Class | Dart.PowerTCP.Telnet Namespace | InvalidParameterTypeException Constructor Overload List


InvalidParameterTypeException Constructor (String)

Initializes a new instance of InvalidParameterTypeException.

[Visual Basic]
Overloads Public Sub New( _
ByVal message As String _
)
[C#]
public InvalidParameterTypeException(
string message
);

See Also

InvalidParameterTypeException Class | Dart.PowerTCP.Telnet Namespace | InvalidParameterTypeException Constructor Overload List


InvalidParameterTypeException Constructor (String, Exception)

Initializes a new instance of InvalidParameterTypeException.

[Visual Basic]
Overloads Public Sub New( _
ByVal message As String, _
ByVal e As Exception _
)
[C#]
public InvalidParameterTypeException(
string message,
Exception e
);

See Also

InvalidParameterTypeException Class | Dart.PowerTCP.Telnet Namespace | InvalidParameterTypeException Constructor Overload List


InvalidParameterTypeException Constructor (String, Int32)

Initializes a new instance of the InvalidParameterException class.

[Visual Basic]
Overloads Public Sub New( _
ByVal description As String, _
ByVal parameterNumber As Integer _
)
[C#]
public InvalidParameterTypeException(
string description,
int parameterNumber
);

See Also

InvalidParameterTypeException Class | Dart.PowerTCP.Telnet Namespace | InvalidParameterTypeException Constructor Overload List


Option Class

Encapsulates a Telnet option.

For a list of all members of this type, see Option Members.

System.Object
Option

[Visual Basic]
Public Class Option
[C#]
public class Option

Remarks

The Telnet protocol allows for option negotiation to provide advanced capabilities to the default NVT (Network Virtual Terminal, see the Telnet Protocol Overview topic for more information). Either the client or server can request to enable or disable a particular option and also can accept or deny a request to enable or disable an option. The Option object represents the option.

To add a new Telnet option, create a new Option object, then add it to the Telnet.ClientOptions or Telnet.ServerOptions collection. Adding the Option to the Telnet.ClientOptions collection causes the Telnet component to send a Will or Wont command to the server concerning the option. Adding the Option to the Telnet.ServerOptions collection causes the Telnet component to sent a Do or Dont command to the server concerning the option. The Option.State can either be set to OptionState.RequestOn, if you do want to use the option, or OptionState.Allow, if you want to use the option only if the other host requests it. If you do not wish to use an option either do not add the option to a OptionCollection or, if it is already in an OptionCollection, use OptionCollection.Remove to remove it. After option negotiation occurs (after either Telnet.Connect or Telnet.Login is called), check the Option.State property to see if the option was negotiated successfully (OptionState.On) or negotiated unsuccessfully (OptionState.Off).

Example

[Visual Basic, C#] The following example demonstrates customizing the default option negotiation sequence.

[Visual Basic]
' Cause the client to refuse the TerminalType option if offered by the server
Telnet1.ClientOptions.Remove(Telnet1.ClientOptions(OptionCode.TerminalType))

' Request that server enable the Echo option
Telnet1.ServerOptions.Add(New Option(OptionCode.Echo))

' ReceiveTimeout must be set to a positive value before using the Login method.
Telnet1.ReceiveTimeout = 3000

' Connect and login to the Telnet server
Telnet1.Login("myserver", "myusername", "mypassword", "$")

' What is the result of option negotiation?
Dim o as Option
For Each o in Telnet1.ClientOptions
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
Next

For Each o in Telnet1.ServerOptions
    Debug.WriteLine("Code: " + o.Code)
    Debug.WriteLine("State: " + o.State)
Next
[C#]
// Cause the client to refuse the TerminalType option if offered by the server
telnet1.ClientOptions.Remove(telnet1.ClientOptions[OptionCode.TerminalType]);

// Request that server enable the Echo option
telnet1.ServerOptions.Add(new Option(OptionCode.Echo));

// Connect and login to the Telnet server
telnet1.Login("myserver", "myusername", "mypassword", "$");

// What is the result of option negotiation?
foreach(Option o in telnet1.ClientOptions)
{
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
}
foreach(Option o in telnet1.ClientOptions)
{
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

Option Members | Dart.PowerTCP.Telnet Namespace


Option Members

Option overview

Public Instance Constructors

Option Overloaded. Initializes a new instance of the Option class.

Public Instance Properties

Code | Gets or sets the code of the option to use.
State | Gets or sets the current state of the Option.
SubOption | Gets or sets the suboption information for options.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
Reset | Reinitializes the Option.State for a new connection.
ToString (inherited from Object) | Returns a String that represents the current Object.

See Also

Option Class | Dart.PowerTCP.Telnet Namespace


Option Constructor

Create a new instance of Option.

Overload List

Create a new instance of Option.

public Option();

Create a new instance of Option.

public Option(OptionCode);

Create a new instance of Option.

public Option(OptionCode,OptionState);

Create a new instance of Option.

public Option(OptionCode,byte[]);

Create a new instance of Option.

public Option(OptionCode,byte[],OptionState);

Create a new instance of Option.

public Option(byte[],int,int);

See Also

Option Class | Dart.PowerTCP.Telnet Namespace


Option Constructor ()

Create a new instance of Option.

[Visual Basic]
Overloads Public Sub New()
[C#]
public Option();

Remarks

This constructor creates a new instance of Option with the Option.State set to OptionState.Off.

See Also

Option Class | Dart.PowerTCP.Telnet Namespace | Option Constructor Overload List


Option Constructor (OptionCode)

Create a new instance of Option.

[Visual Basic]
Overloads Public Sub New( _
ByVal code As OptionCode _
)
[C#]
public Option(
OptionCode code
);

Parameters

code
The OptionCode of the Option

Remarks

This constructor creates a new instance of Option, with the Option.Code property set to the value of code and the Option.State set to OptionState.Off.

See Also

Option Class | Dart.PowerTCP.Telnet Namespace | Option Constructor Overload List


Option Constructor (OptionCode, OptionState)

Create a new instance of Option.

[Visual Basic]
Overloads Public Sub New( _
ByVal code As OptionCode, _
ByVal state As OptionState _
)
[C#]
public Option(
OptionCode code,
OptionState state
);

Parameters

code
The OptionCode of the Option.
state
The OptionState of the Option.

Remarks

This constructor creates a new instance of Option, with the Option.Code property set to the value of code and the Option.State property set to the value to state.

See Also

Option Class | Dart.PowerTCP.Telnet Namespace | Option Constructor Overload List


Option Constructor (OptionCode, Byte[])

Create a new instance of Option.

[Visual Basic]
Overloads Public Sub New( _
ByVal code As OptionCode, _
ByVal subOption As Byte() _
)
[C#]
public Option(
OptionCode code,
byte[] subOption
);

Parameters

code
The OptionCode of the Option.
subOption
The SubOption of the Option.

Remarks

This constructor creates a new instance of Option, with the Option.Code property set to the value of code and the Option.SubOption property set to the value of subOption and the Option.State set to OptionState.Off. .

See Also

Option Class | Dart.PowerTCP.Telnet Namespace | Option Constructor Overload List


Option Constructor (OptionCode, Byte[], OptionState)

Create a new instance of Option.

[Visual Basic]
Overloads Public Sub New( _
ByVal code As OptionCode, _
ByVal subOption As Byte(), _
ByVal state As OptionState _
)
[C#]
public Option(
OptionCode code,
byte[] subOption,
OptionState state
);

Remarks

This constructor creates a new instance of Option with the Option.State set to OptionState.Off.

See Also

Option Class | Dart.PowerTCP.Telnet Namespace | Option Constructor Overload List


Option Constructor (Byte[], Int32, Int32)

Create a new instance of Option.

[Visual Basic]
Overloads Public Sub New( _
ByVal buffer As Byte(), _
ByVal offset As Integer, _
ByVal count As Integer _
)
[C#]
public Option(
byte[] buffer,
int offset,
int count
);

Parameters

buffer
Contains option data.
offset
Contains the offset into buffer.
count
Contains the count of option data.

Remarks

This constructor creates a new instance of Option with the Option.State set to OptionState.Off.

See Also

Option Class | Dart.PowerTCP.Telnet Namespace | Option Constructor Overload List


Option Properties

The properties of the Option class are listed below. For a complete list of Option class members, see the Option Members topic.

Public Instance Properties

Code | Gets or sets the code of the option to use.
State | Gets or sets the current state of the Option.
SubOption | Gets or sets the suboption information for options.

See Also

Option Class | Dart.PowerTCP.Telnet Namespace


Option.Code Property

Gets or sets the code of the option to use.

[Visual Basic]
Public Property Code As OptionCode
[C#]
public OptionCode Code {get; set;}

Property Value

A OptionCode value representing the code for the option.

Remarks

This property will reflect one of the defined Telnet option code values represented by the OptionCode enumeration. For information about each option, please see the RFC for that option.

Example

[Visual Basic, C#] The following example demonstrates customizing the default option negotiation sequence.

[Visual Basic]
' Cause the client to refuse the TerminalType option if offered by the server
Telnet1.ClientOptions.Remove(Telnet1.ClientOptions(OptionCode.TerminalType))

' Request that server enable the Echo option
Telnet1.ServerOptions.Add(New Option(OptionCode.Echo))

' ReceiveTimeout must be set to a positive value before using the Login method.
Telnet1.ReceiveTimeout = 3000

' Connect and login to the Telnet server
Telnet1.Login("myserver", "myusername", "mypassword", "$")

' What is the result of option negotiation?
Dim o as Option
For Each o in Telnet1.ClientOptions
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
Next

For Each o in Telnet1.ServerOptions
    Debug.WriteLine("Code: " + o.Code)
    Debug.WriteLine("State: " + o.State)
Next
[C#]
// Cause the client to refuse the TerminalType option if offered by the server
telnet1.ClientOptions.Remove(telnet1.ClientOptions[OptionCode.TerminalType]);

// Request that server enable the Echo option
telnet1.ServerOptions.Add(new Option(OptionCode.Echo));

// Connect and login to the Telnet server
telnet1.Login("myserver", "myusername", "mypassword", "$");

// What is the result of option negotiation?
foreach(Option o in telnet1.ClientOptions)
{
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
}
foreach(Option o in telnet1.ClientOptions)
{
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Option Class | Dart.PowerTCP.Telnet Namespace


Option.State Property

Gets or sets the current state of the Option.

[Visual Basic]
Public Property State As OptionState
[C#]
public OptionState State {get; set;}

Property Value

An OptionCode value representing the current state of the Option.

Remarks

Option negotiation with PowerTCP Telnet for NET can be broken down into three general states:

State 1 - Setting the option:

You must add any options you wish to request into either the Telnet.ClientOptions or Telnet.ServerOptions collections. Any Options added to this collection are part of the automatic option negotiation. When adding new Options to the collection:

  • Set to OptionState.RequestOn if you would like to request the option.
  • Set to OptionState.Allow if you would like to enable the option only if the other host requests it.
  • Remove the Option from the collection if you do not wish to request the option and want to respond negatively to server requests.

State 2 - Requesting the option:

Once all options have been set and added to the collection, option negotiation needs to occur with the remote host. This typically is handled internally by the Telnet component when a new connection occurs. During this time the Option.Code property is OptionCode.Waiting, meaning a request has been sent but a response has not yet been received.

State 3 - Negotiation complete:

After option negotiation has completed, check the Option.Code property to see the results of the negotiation. It should reflect one of two values:

  • The Option.Code property is OptionCode.Off if the option is not used.
  • The Option.Code property is OptionCode.On if the option is used.

Example

[Visual Basic, C#] The following example demonstrates customizing the default option negotiation sequence.

[Visual Basic]
' Cause the client to refuse the TerminalType option if offered by the server
Telnet1.ClientOptions.Remove(Telnet1.ClientOptions(OptionCode.TerminalType))

' Request that server enable the Echo option
Telnet1.ServerOptions.Add(New Option(OptionCode.Echo))

' ReceiveTimeout must be set to a positive value before using the Login method.
Telnet1.ReceiveTimeout = 3000

' Connect and login to the Telnet server
Telnet1.Login("myserver", "myusername", "mypassword", "$")

' What is the result of option negotiation?
Dim o as Option
For Each o in Telnet1.ClientOptions
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
Next

For Each o in Telnet1.ServerOptions
    Debug.WriteLine("Code: " + o.Code)
    Debug.WriteLine("State: " + o.State)
Next
[C#]
// Cause the client to refuse the TerminalType option if offered by the server
telnet1.ClientOptions.Remove(telnet1.ClientOptions[OptionCode.TerminalType]);

// Request that server enable the Echo option
telnet1.ServerOptions.Add(new Option(OptionCode.Echo));

// Connect and login to the Telnet server
telnet1.Login("myserver", "myusername", "mypassword", "$");

// What is the result of option negotiation?
foreach(Option o in telnet1.ClientOptions)
{
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
}
foreach(Option o in telnet1.ClientOptions)
{
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Option Class | Dart.PowerTCP.Telnet Namespace


Option.SubOption Property

Gets or sets the suboption information for options.

[Visual Basic]
Public Property SubOption As Byte()
[C#]
public byte[] SubOption {get; set;}

Property Value

A byte array representing the suboption information.

Remarks

Some options require addition suboption information. Set this property to the byte array representing the suboption data. The formatting of the data in the byte array may vary depending on the opion. See the RFC for the option to determine how to format the data in the byte array.

Some often used suboptions are encapsulated by high level properties for ease of use. Some examples are the Telnet.TerminalType property, the Telnet.Echo property and the Telnet.Binary property.

See Also

Option Class | Dart.PowerTCP.Telnet Namespace


Option Methods

The methods of the Option class are listed below. For a complete list of Option class members, see the Option Members topic.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
Reset | Reinitializes the Option.State for a new connection.
ToString (inherited from Object) | Returns a String that represents the current Object.

See Also

Option Class | Dart.PowerTCP.Telnet Namespace


Option.Reset Method

Reinitializes the Option.State for a new connection.

[Visual Basic]
Public Sub Reset()
[C#]
public void Reset();

Remarks

This method causes the Option.State property of the Option object to revert back to it's original state when it was added to an OptionCollection If the Option.State was OptionState.RequestOff, it is set to OptionState.Off.

See Also

Option Class | Dart.PowerTCP.Telnet Namespace


OptionCode Enumeration

Enumerates the supported options.

[Visual Basic]
Public Enum OptionCode
[C#]
public enum OptionCode

Remarks

The Telnet protocol defines a framework within which both sides of a Telnet connection can negotiate options, enhancing the NVT. For information on a particular link below, please consult the RFC for the option.

Example

[Visual Basic, C#] The following example demonstrates customizing the default option negotiation sequence.

[Visual Basic]
' Cause the client to refuse the TerminalType option if offered by the server
Telnet1.ClientOptions.Remove(Telnet1.ClientOptions(OptionCode.TerminalType))

' Request that server enable the Echo option
Telnet1.ServerOptions.Add(New Option(OptionCode.Echo))

' ReceiveTimeout must be set to a positive value before using the Login method.
Telnet1.ReceiveTimeout = 3000

' Connect and login to the Telnet server
Telnet1.Login("myserver", "myusername", "mypassword", "$")

' What is the result of option negotiation?
Dim o as Option
For Each o in Telnet1.ClientOptions
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
Next

For Each o in Telnet1.ServerOptions
    Debug.WriteLine("Code: " + o.Code)
    Debug.WriteLine("State: " + o.State)
Next
[C#]
// Cause the client to refuse the TerminalType option if offered by the server
telnet1.ClientOptions.Remove(telnet1.ClientOptions[OptionCode.TerminalType]);

// Request that server enable the Echo option
telnet1.ServerOptions.Add(new Option(OptionCode.Echo));

// Connect and login to the Telnet server
telnet1.Login("myserver", "myusername", "mypassword", "$");

// What is the result of option negotiation?
foreach(Option o in telnet1.ClientOptions)
{
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
}
foreach(Option o in telnet1.ClientOptions)
{
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Members

Member Name | Description
None | -1 No option used.
TransmitBinary | 0 TRANSMIT-BINARY option. Used to request or confirm that received data is to be interpreted as 8 bits of binary data. See RFC 856 for more information.
Echo | 1 ECHO option. Used to request or confirm that characters received are echoed back to the NVT. See RFC 857 for more information.
SuppressGoAheads | 3 SUPPRESS-GO-AHEAD option. Used to request or confirm that the GO-AHEAD is not sent. See RFC 858 for more information.
ApproxMessageSize | 4 Approx Message Size Negotiation option.
Status | 5 STATUS option. Used to request or confirm the receiver's current option status. See RFC 859 for more information.
TimingMark | 6 TIMING-MARK option. Used to request or or send a TIMING-MARK echo, used for synchronization. See RFC 860 for more information.
RemoteControlledTransAndEcho | 7 Remote Controlled Transmssion and Echoing Telnet option. See RFC 563 and RFC 726for more information.
OutputLineWidth | 8 Output Line Width option.
OutputPageSize | 9 Output Page Size option.
OutputCarriageReturnDisp | 10 Negotiate About Output Carriage-Return Disposition option. See RFC 652 for more information.
OutputHorizontalTabstops | 11 Negotiate About Output Horizontal Tabstops option. See RFC 653 for more information.
OutputHorizontalTabDisp | 12 Negotiate About Output Horizontal Tab Disposition option. See RFC 654 for more information.
OutputFormfeedDisp | 13 Negotiate About Output Formfeed Disposition option. See RFC 655 for more information.
OutputVerticalTabstops | 14 Negotiate About Vertical Tabstops option. See RFC 656 for more information.
OutputVerticalTabDisp | 15 Negotiate About Output Vertcial Tab Disposition option. See RFC 657 for more information.
OutputLinefeedDisp | 16 Negotiate About Output Linefeed Disposition option. See RFC 658 for more information.
ExtendedAscii | 17 EXTENDED-ASCII option. Used to request or confirm that extended ASCII may be transmitted. See RFC 698 for more information.
Logout | 18 LOGOUT option. Used to request or confirm that the other client is forcibly logged off at the end. See RFC 727 for more information.
ByteMacro | 19 Byte-Macro option. Used to request or confirm that macro bytes may be used in place of certain strings. See RFC 735 for more information.
DataEntryTerminal | 20 Data Entry Terminal option. Used to request or agree to send or receive commands to control the Data Entry Terminal. See RFC 732 or RFC 1043for more information.
SupDup | 21 SUPDUP option. See RFC 734 or RFC 736for more information.
SupDupOutput | 22 SUPDUP-Output option. See RFC 749 for more information.
SendLocation | 23 SEND-LOCATION option. Used to request or confirm that the user can send their location to the Telnet server. See RFC 779 for more information.
TerminalType | 24 TERMINAL-TYPE option. Used to request or confirm that terminal-type is sent in a subsequent suboption. See RFC 1091 for more information.
EndOfRecord | 25 END-OF-RECORD option. Used to request or confirm that the EOR character can be used when sending data to delimit blocks of data or records. See RFC 885 for more information.
TacacsUserIdentification | 26 TACACS User Identification Telnet option. Designed to facilitate double login avoidence for communication between TAC hosts. See RFC 927 for more information.
OutputMarking | 27 Output Marking Telnet option. Designed to allow a Server to send a banner to a User so that this banner would be displayed on the screen independently of the application software running in the Server. See RFC 933 for more information.
TerminalLocation | 28 Terminal Location Number option. Used to request or confirm usage of a TTYLOC. See RFC 946 for more information.
Regime3270 | 29 3270 Regime option. Used to request or confirm that 3270 Regimes be supported. See RFC 1041 for more information.
X3Pad | 30 X.3 Pad option. See RFC 1035 for more information.
WindowSize | 31 Negotiate About Window Size option. Used by a client to request if they can convey window size to a server. See RFC 1073 for more information.
TerminalSpeed | 32 Terminal Speed option. Used to request or confirm that terminal speed information can be sent in a suboption. See RFC 1079 for more information.
ToggleFlowControl | 33 Remote Flow Control option. Used to request or confirm that flow control can be used. See RFC 1372 for more information.
LineMode | 34 Linemode option. Used to request or confirm that linemode is used. See RFC 1184 for more information.
XDisplayLocation | 35 X Display Location option. Used to request or confirm that the X display location of the client can be sent to the server. See RFC 1096 for more information.
Environment | 36 Environment option. Used to request or confirm that environment information can be passed between hosts. See RFC 1408 for more information.
Authentication | 37 Authentication option. Used to request or confirm that the host is willing to send authentication information. See RFC 1416, RFC 2941, RFC 2942, RFC 2943, and RFC 2951 for more information.
EncryptionOption | 38 Data Encryption option. Used to request or confirm that the host is willing to send/receive encrypted data. See RFC 2946 for more information.
NewEnvironment | 39 Environment option. Used to request or confirm that environment information can be passed between hosts. See RFC 1572 for more information.
TN3270E | 40 TN3270 option. Used to request or confirm that 3270 device family enhancements can be used. See RFC 2355 for more information.
Xauth | 41 XAUTH option.
CharacterSet | 42 CHARSET option. Used to request or confirm that character set information can be passed between hosts. See RFC 2066 for more information.
RemoteSerialPort | 43 RSP option. Telnet remote serial port.
ComPort | 44 Com Port Control option. See RFC 2217 for more information.
SuppressLocalEcho | 45 Suppress local echo option.
StartTls | 46 Start TLS option.
Kermit | 47 Kermit option. Used to request or confirm the communication can use the Kermit protocol. See RFC 2840 for more information.
SendUrl | 48 SEND-URL option.
ForwardX | 49 FORWARD_X option.
PragmaLogon | 138 TELOPT PRAGMA LOGON option.
SspiLogon | 139 TELOPT SSPI LOGON option.
PragmaHeartbeat | 140 TELOPT PRAGMA HEARTBEAT option.
ExtendedOptionsList | 255 EXOPL, Extended-Options-List option.

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

Dart.PowerTCP.Telnet Namespace


OptionCollection Class

A collection of Option objects.

For a list of all members of this type, see OptionCollection Members.

System.Object
ArrayList
OptionCollection

[Visual Basic]
Public Class OptionCollection
Inherits ArrayList
[C#]
public class OptionCollection : ArrayList

Remarks

When using PowerTCP Telnet for .NET, the OptionCollection object is a collection of Option objects representing the options to be used in option negotiation. Access the client OptionCollection object via the Telnet.ClientOptions property. Access the server OptionCollection object via the Telnet.ServerOptions property.

Example

[Visual Basic, C#] The following example demonstrates customizing the default option negotiation sequence.

[Visual Basic]
' Cause the client to refuse the TerminalType option if offered by the server
Telnet1.ClientOptions.Remove(Telnet1.ClientOptions(OptionCode.TerminalType))

' Request that server enable the Echo option
Telnet1.ServerOptions.Add(New Option(OptionCode.Echo))

' ReceiveTimeout must be set to a positive value before using the Login method.
Telnet1.ReceiveTimeout = 3000

' Connect and login to the Telnet server
Telnet1.Login("myserver", "myusername", "mypassword", "$")

' What is the result of option negotiation?
Dim o as Option
For Each o in Telnet1.ClientOptions
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
Next

For Each o in Telnet1.ServerOptions
    Debug.WriteLine("Code: " + o.Code)
    Debug.WriteLine("State: " + o.State)
Next
[C#]
// Cause the client to refuse the TerminalType option if offered by the server
telnet1.ClientOptions.Remove(telnet1.ClientOptions[OptionCode.TerminalType]);

// Request that server enable the Echo option
telnet1.ServerOptions.Add(new Option(OptionCode.Echo));

// Connect and login to the Telnet server
telnet1.Login("myserver", "myusername", "mypassword", "$");

// What is the result of option negotiation?
foreach(Option o in telnet1.ClientOptions)
{
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
}
foreach(Option o in telnet1.ClientOptions)
{
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

OptionCollection Members | Dart.PowerTCP.Telnet Namespace


OptionCollection Members

OptionCollection overview

Public Instance Constructors

OptionCollection Constructor Create a new instance of the OptionCollection object.

Public Instance Properties

Capacity (inherited from ArrayList) | Gets or sets the number of elements that the ArrayList can contain.
Count (inherited from ArrayList) | Gets the number of elements actually contained in the ArrayList.
IsFixedSize (inherited from ArrayList) | Gets a value indicating whether the ArrayList has a fixed size.
IsReadOnly (inherited from ArrayList) | Gets a value indicating whether the ArrayList is read-only.
IsSynchronized (inherited from ArrayList) | Gets a value indicating whether access to the ArrayList is synchronized (thread-safe).
Item | Overloaded. Gets the Option object at the specified index.
SyncRoot (inherited from ArrayList) | Gets an object that can be used to synchronize access to the ArrayList.
TransmitBinary | Returns a value which reflects if the "TRANSMIT-BINARY" option was negotiated for the OptionCollection.

Public Instance Methods

Add (inherited from ArrayList) | Overloaded. Adds an object to the end of the ArrayList.
Add | Overloaded. Add a new Option objects to the OptionCollection object.
AddRange (inherited from ArrayList) | Overloaded. Adds the elements of an ICollection to the end of the ArrayList.
AddRange | Overloaded. Add an array of Option objects to the OptionCollection.
BinarySearch (inherited from ArrayList) | Overloaded. Searches the entire sorted ArrayList for an element using the specified comparer and returns the zero-based index of the element.
Clear (inherited from ArrayList) | Removes all elements from the ArrayList.
Clone (inherited from ArrayList) | Creates a shallow copy of the ArrayList.
Contains (inherited from ArrayList) | Overloaded. Determines whether an element is in the ArrayList.
Contains | Overloaded. Determines whether an element is in the collection.
CopyTo (inherited from ArrayList) | Overloaded. Copies the entire ArrayList to a compatible one-dimensional Array, starting at the specified index of the target array.
CopyTo | Overloaded. Copies the entire collection to a compatible one-dimensional Array, starting at the specified index of the target array.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetEnumerator (inherited from ArrayList) | Overloaded. Returns an enumerator for the entire ArrayList.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetRange (inherited from ArrayList) | Returns an ArrayList which represents a subset of the elements in the source ArrayList.
GetType (inherited from Object) | Gets the Type of the current instance.
IndexOf (inherited from ArrayList) | Overloaded. Searches for the specified Object and returns the zero-based index of the first occurrence within the entire ArrayList.
IndexOf | Overloaded. Searches for the specified value and returns the zero-based index of the first occurrence within the entire collection.
Insert (inherited from ArrayList) | Overloaded. Inserts an element into the ArrayList at the specified index.
Insert | Overloaded. Inserts an element into the collection at the specified index.
InsertRange (inherited from ArrayList) | Inserts the elements of a collection into the ArrayList at the specified index.
LastIndexOf (inherited from ArrayList) | Overloaded. Searches for the specified Object and returns the zero-based index of the last occurrence within the section of the ArrayList that contains the specified number of elements and ends at the specified index.
Remove (inherited from ArrayList) | Overloaded. Removes the first occurrence of a specific object from the ArrayList.
Remove | Overloaded. Removes the Option object which is equal to the specified option.
RemoveAt (inherited from ArrayList) | Removes the element at the specified index of the ArrayList.
RemoveRange (inherited from ArrayList) | Removes a range of elements from the ArrayList.
Reverse (inherited from ArrayList) | Overloaded. Reverses the order of the elements in the specified range.
SetRange (inherited from ArrayList) | Copies the elements of a collection over a range of elements in the ArrayList.
Sort (inherited from ArrayList) | Overloaded. Sorts the elements in a section of ArrayList using the specified comparer.
ToArray (inherited from ArrayList) | Overloaded. Copies the elements of the ArrayList to a new array of the specified type.
ToString (inherited from Object) | Returns a String that represents the current Object.
TrimToSize (inherited from ArrayList) | Sets the capacity to the actual number of elements in the ArrayList.

See Also

OptionCollection Class | Dart.PowerTCP.Telnet Namespace


OptionCollection Constructor

Create a new instance of the OptionCollection object.

[Visual Basic]
Public Sub New()
[C#]
public OptionCollection();

Remarks

The default constructor creates a new instance of the Options object.

See Also

OptionCollection Class | Dart.PowerTCP.Telnet Namespace


OptionCollection Properties

The properties of the OptionCollection class are listed below. For a complete list of OptionCollection class members, see the OptionCollection Members topic.

Public Instance Properties

Capacity (inherited from ArrayList) | Gets or sets the number of elements that the ArrayList can contain.
Count (inherited from ArrayList) | Gets the number of elements actually contained in the ArrayList.
IsFixedSize (inherited from ArrayList) | Gets a value indicating whether the ArrayList has a fixed size.
IsReadOnly (inherited from ArrayList) | Gets a value indicating whether the ArrayList is read-only.
IsSynchronized (inherited from ArrayList) | Gets a value indicating whether access to the ArrayList is synchronized (thread-safe).
Item | Overloaded. Gets the Option object at the specified index.
SyncRoot (inherited from ArrayList) | Gets an object that can be used to synchronize access to the ArrayList.
TransmitBinary | Returns a value which reflects if the "TRANSMIT-BINARY" option was negotiated for the OptionCollection.

See Also

OptionCollection Class | Dart.PowerTCP.Telnet Namespace


Item Property

PowerTCP Telnet for .NET

OptionCollection.Item Property

Gets the Option object which matches the specified OptionCode.

Overload List

Gets the Option object which matches the specified OptionCode.

public Option this[Dart.PowerTCP.Telnet.OptionCode] {get; set;}

Gets the Option object at the specified index.

public Option this[int] {get; set;}

See Also

OptionCollection Class | Dart.PowerTCP.Telnet Namespace


OptionCollection.Item Property

Gets the Option object which matches the specified OptionCode.

[Visual Basic]
Overloads Public Default Property Item( _
ByVal code As OptionCode _
) As Option
[C#]
public Option this[
Dart.PowerTCP.Telnet.OptionCode code
] {get; set;}

Remarks

Returns the Option object with the specified OptionCode, or null if no element matching the OptionCode is found.

See Also

OptionCollection Class | Dart.PowerTCP.Telnet Namespace | OptionCollection.Item Overload List


OptionCollection.Item Property

Gets the Option object at the specified index.

[Visual Basic]
Overloads Public Default Property Item( _
ByVal index As Integer _
) As Option
[C#]
public Option this[
int index
] {get; set;}

Remarks

Returns the Option object at the specified index.

See Also

OptionCollection Class | Dart.PowerTCP.Telnet Namespace | OptionCollection.Item Overload List


OptionCollection.TransmitBinary Property

Returns a value which reflects if the "TRANSMIT-BINARY" option was negotiated for the OptionCollection.

[Visual Basic]
Public ReadOnly Property TransmitBinary As Boolean
[C#]
public bool TransmitBinary {get;}

Property Value

A boolean which determines if the TRANSMIT-BINARY option has been negotiated.

Remarks

Setting the Telnet.Binary property to true will cause the Telnet component to attempt to negotiate the "TRANSMIT-BINARY" option for both Telnet.ClientOptions and Telnet.ServerOptions. Check the TransmitBinary property for both of these collections after option negotiation has completed to determine if negotiation is successful.

See Also

OptionCollection Class | Dart.PowerTCP.Telnet Namespace


OptionCollection Methods

The methods of the OptionCollection class are listed below. For a complete list of OptionCollection class members, see the OptionCollection Members topic.

Public Instance Methods

Add (inherited from ArrayList) | Overloaded. Adds an object to the end of the ArrayList.
Add | Overloaded. Add a new Option objects to the OptionCollection object.
AddRange (inherited from ArrayList) | Overloaded. Adds the elements of an ICollection to the end of the ArrayList.
AddRange | Overloaded. Add an array of Option objects to the OptionCollection.
BinarySearch (inherited from ArrayList) | Overloaded. Searches the entire sorted ArrayList for an element using the specified comparer and returns the zero-based index of the element.
Clear (inherited from ArrayList) | Removes all elements from the ArrayList.
Clone (inherited from ArrayList) | Creates a shallow copy of the ArrayList.
Contains (inherited from ArrayList) | Overloaded. Determines whether an element is in the ArrayList.
Contains | Overloaded. Determines whether an element is in the collection.
CopyTo (inherited from ArrayList) | Overloaded. Copies the entire ArrayList to a compatible one-dimensional Array, starting at the specified index of the target array.
CopyTo | Overloaded. Copies the entire collection to a compatible one-dimensional Array, starting at the specified index of the target array.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetEnumerator (inherited from ArrayList) | Overloaded. Returns an enumerator for the entire ArrayList.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetRange (inherited from ArrayList) | Returns an ArrayList which represents a subset of the elements in the source ArrayList.
GetType (inherited from Object) | Gets the Type of the current instance.
IndexOf (inherited from ArrayList) | Overloaded. Searches for the specified Object and returns the zero-based index of the first occurrence within the entire ArrayList.
IndexOf | Overloaded. Searches for the specified value and returns the zero-based index of the first occurrence within the entire collection.
Insert (inherited from ArrayList) | Overloaded. Inserts an element into the ArrayList at the specified index.
Insert | Overloaded. Inserts an element into the collection at the specified index.
InsertRange (inherited from ArrayList) | Inserts the elements of a collection into the ArrayList at the specified index.
LastIndexOf (inherited from ArrayList) | Overloaded. Searches for the specified Object and returns the zero-based index of the last occurrence within the section of the ArrayList that contains the specified number of elements and ends at the specified index.
Remove (inherited from ArrayList) | Overloaded. Removes the first occurrence of a specific object from the ArrayList.
Remove | Overloaded. Removes the Option object which is equal to the specified option.
RemoveAt (inherited from ArrayList) | Removes the element at the specified index of the ArrayList.
RemoveRange (inherited from ArrayList) | Removes a range of elements from the ArrayList.
Reverse (inherited from ArrayList) | Overloaded. Reverses the order of the elements in the specified range.
SetRange (inherited from ArrayList) | Copies the elements of a collection over a range of elements in the ArrayList.
Sort (inherited from ArrayList) | Overloaded. Sorts the elements in a section of ArrayList using the specified comparer.
ToArray (inherited from ArrayList) | Overloaded. Copies the elements of the ArrayList to a new array of the specified type.
ToString (inherited from Object) | Returns a String that represents the current Object.
TrimToSize (inherited from ArrayList) | Sets the capacity to the actual number of elements in the ArrayList.

See Also

OptionCollection Class | Dart.PowerTCP.Telnet Namespace


Add Method

PowerTCP Telnet for .NET

OptionCollection.Add Method

Add a new Option objects to the OptionCollection object.

Overload List

Add a new Option objects to the OptionCollection object.

public int Add(Option);

Inherited from ArrayList.

public virtual int Add(object);

See Also

OptionCollection Class | Dart.PowerTCP.Telnet Namespace


OptionCollection.Add Method (Option)

Add a new Option objects to the OptionCollection object.

[Visual Basic]
Overloads Public Function Add( _
ByVal value As Option _
) As Integer
[C#]
public int Add(
Option value
);

Parameters

value
The Option object to add to the OptionCollection object.

Return Value

The index at which the object was added.

Remarks

Use this method to add a new Option object to the OptionCollection object. Adding an option to the collection will ensure that it is used for option negotiation.

If an object is found in the collection which has the same Option.Code as the new option, this Option is first removed to ensure no duplicate options are in the collection.

Example

[Visual Basic, C#] The following example demonstrates customizing the default option negotiation sequence.

[Visual Basic]
' Cause the client to refuse the TerminalType option if offered by the server
Telnet1.ClientOptions.Remove(Telnet1.ClientOptions(OptionCode.TerminalType))

' Request that server enable the Echo option
Telnet1.ServerOptions.Add(New Option(OptionCode.Echo))

' ReceiveTimeout must be set to a positive value before using the Login method.
Telnet1.ReceiveTimeout = 3000

' Connect and login to the Telnet server
Telnet1.Login("myserver", "myusername", "mypassword", "$")

' What is the result of option negotiation?
Dim o as Option
For Each o in Telnet1.ClientOptions
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
Next

For Each o in Telnet1.ServerOptions
    Debug.WriteLine("Code: " + o.Code)
    Debug.WriteLine("State: " + o.State)
Next
[C#]
// Cause the client to refuse the TerminalType option if offered by the server
telnet1.ClientOptions.Remove(telnet1.ClientOptions[OptionCode.TerminalType]);

// Request that server enable the Echo option
telnet1.ServerOptions.Add(new Option(OptionCode.Echo));

// Connect and login to the Telnet server
telnet1.Login("myserver", "myusername", "mypassword", "$");

// What is the result of option negotiation?
foreach(Option o in telnet1.ClientOptions)
{
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
}
foreach(Option o in telnet1.ClientOptions)
{
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

OptionCollection Class | Dart.PowerTCP.Telnet Namespace | OptionCollection.Add Overload List


AddRange Method

PowerTCP Telnet for .NET

OptionCollection.AddRange Method

Add an array of Option objects to the OptionCollection.

Overload List

Add an array of Option objects to the OptionCollection.

public void AddRange(Option[]);

Inherited from ArrayList.

public virtual void AddRange(ICollection);

See Also

OptionCollection Class | Dart.PowerTCP.Telnet Namespace


OptionCollection.AddRange Method (Option[])

Add an array of Option objects to the OptionCollection.

[Visual Basic]
Overloads Public Sub AddRange( _
ByVal items As Option() _
)
[C#]
public void AddRange(
Option[] items
);

Parameters

items
The array of Option objects to add to the OptionCollection.

Remarks

Use this method to add an array of Option objects to the OptionCollection. Adding an option to the collection will ensure that it is used for option negotiation.

If an object is found in the collection which has the same Option.Code as the new option, this Option is first removed to ensure no duplicate options are in the collection.

See Also

OptionCollection Class | Dart.PowerTCP.Telnet Namespace | OptionCollection.AddRange Overload List


Contains Method

PowerTCP Telnet for .NET

OptionCollection.Contains Method

Determines whether an element is in the collection.

Overload List

Determines whether an element is in the collection.

public bool Contains(Option);

Inherited from ArrayList.

public virtual bool Contains(object);

See Also

OptionCollection Class | Dart.PowerTCP.Telnet Namespace


OptionCollection.Contains Method (Option)

Determines whether an element is in the collection.

[Visual Basic]
Overloads Public Function Contains( _
ByVal value As Option _
) As Boolean
[C#]
public bool Contains(
Option value
);

Parameters

value
The Object to locate in the collection. The element to locate can be a null reference (Nothing in Visual Basic).

Return Value

true if item is found in the collection; otherwise, false.

Remarks

This method performs a linear search; therefore, the average execution time is proportional to Count. That is, this method is an O(n) operation, where n is Count.

This method determines equality by calling Object.Equals.

See Also

OptionCollection Class | Dart.PowerTCP.Telnet Namespace | OptionCollection.Contains Overload List


CopyTo Method

PowerTCP Telnet for .NET

OptionCollection.CopyTo Method

Copies the entire collection to a compatible one-dimensional Array, starting at the specified index of the target array.

Overload List

Copies the entire collection to a compatible one-dimensional Array, starting at the specified index of the target array.

public void CopyTo(Option[],int);

Inherited from ArrayList.

public virtual void CopyTo(Array);

Inherited from ArrayList.

public virtual void CopyTo(Array,int);

Inherited from ArrayList.

public virtual void CopyTo(int,Array,int,int);

See Also

OptionCollection Class | Dart.PowerTCP.Telnet Namespace


OptionCollection.CopyTo Method (Option[], Int32)

Copies the entire collection to a compatible one-dimensional Array, starting at the specified index of the target array.

[Visual Basic]
Overloads Public Sub CopyTo( _
ByVal array As Option(), _
ByVal index As Integer _
)
[C#]
public void CopyTo(
Option[] array,
int index
);

Parameters

array
The one-dimensional Array that is the destination of the elements copied from ArrayList. The Array must have zero-based indexing.
index
The zero-based index in array at which copying begins.

Remarks

The specified array must be of a compatible type.

This method uses Array.Copy to copy the elements.

Exceptions

Exception Type | Condition
ArgumentNullException | array is a null reference (Nothing in Visual Basic).
ArgumentException | array is multidimensional.
InvalidCastException | The type of the source ArrayList cannot be cast automatically to the type of the destination array.

See Also

OptionCollection Class | Dart.PowerTCP.Telnet Namespace | OptionCollection.CopyTo Overload List


IndexOf Method

PowerTCP Telnet for .NET

OptionCollection.IndexOf Method

Searches for the specified value and returns the zero-based index of the first occurrence within the entire collection.

Overload List

Searches for the specified value and returns the zero-based index of the first occurrence within the entire collection.

public int IndexOf(Option);

Inherited from ArrayList.

public virtual int IndexOf(object);

Inherited from ArrayList.

public virtual int IndexOf(object,int);

Inherited from ArrayList.

public virtual int IndexOf(object,int,int);

See Also

OptionCollection Class | Dart.PowerTCP.Telnet Namespace


OptionCollection.IndexOf Method (Option)

Searches for the specified value and returns the zero-based index of the first occurrence within the entire collection.

[Visual Basic]
Overloads Public Function IndexOf( _
ByVal value As Option _
) As Integer
[C#]
public int IndexOf(
Option value
);

Parameters

value
The Object to locate in the collection.

Return Value

The zero-based index of the first occurrence of value within the entire collection, if found; otherwise, -1.

Remarks

The collection is searched forward starting at the first element and ending at the last element.

This method performs a linear search. On average, this is an O(n/2) operation, where n is Count. The longest search is an O(n) operation.

This method determines equality by calling Object.Equals.

See Also

OptionCollection Class | Dart.PowerTCP.Telnet Namespace | OptionCollection.IndexOf Overload List


Insert Method

PowerTCP Telnet for .NET

OptionCollection.Insert Method

Inserts an element into the collection at the specified index.

Overload List

Inserts an element into the collection at the specified index.

public void Insert(int,Option);

Inherited from ArrayList.

public virtual void Insert(int,object);

See Also

OptionCollection Class | Dart.PowerTCP.Telnet Namespace


OptionCollection.Insert Method (Int32, Option)

Inserts an element into the collection at the specified index.

[Visual Basic]
Overloads Public Sub Insert( _
ByVal index As Integer, _
ByVal value As Option _
)
[C#]
public void Insert(
int index,
Option value
);

Parameters

index
The zero-based index at which value should be inserted.
value
The Object to insert.

Remarks

If Count already equals Capacity, the capacity of the list is doubled by automatically reallocating the internal array before the new element is inserted.

If index is equal to Count, value is added to the end of ArrayList.

In collections of contiguous elements, such as lists, the elements that follow the insertion point move down to accommodate the new element. If the collection is indexed, the indexes of the elements that are moved are also updated. This behavior does not apply to collections where elements are conceptually grouped into buckets, such as a hashtable.

Exceptions

Exception Type | Condition
ArgumentOutOfRangeException | index is less than zero. -or- index is greater than Count.
NotSupportedException | The ArrayList is read-only. -or- The ArrayList has a fixed size.

See Also

OptionCollection Class | Dart.PowerTCP.Telnet Namespace | OptionCollection.Insert Overload List


Remove Method

PowerTCP Telnet for .NET

OptionCollection.Remove Method

Removes the Option object which is equal to the specified option.

Overload List

Removes the Option object which is equal to the specified option.

public void Remove(Option);

Inherited from ArrayList.

public virtual void Remove(object);

See Also

OptionCollection Class | Dart.PowerTCP.Telnet Namespace


OptionCollection.Remove Method (Option)

Removes the Option object which is equal to the specified option.

[Visual Basic]
Overloads Public Sub Remove( _
ByVal value As Option _
)
[C#]
public void Remove(
Option value
);

Parameters

value
The Option to remove from the collection.

Remarks

The Remove method removes the Option object from the OptionCollection which is equal to the Option passed in as option.

See Also

OptionCollection Class | Dart.PowerTCP.Telnet Namespace | OptionCollection.Remove Overload List


OptionEventArgs Class

Provides data for the Telnet.ClientOptionChanged and Telnet.ServerOptionChanged events

For a list of all members of this type, see OptionEventArgs Members.

System.Object
EventArgs
OptionEventArgs

[Visual Basic]
Public Class OptionEventArgs
Inherits EventArgs
[C#]
public class OptionEventArgs : EventArgs

Remarks

An instance of the OptionEventArgs type is a paramter of the Telnet.ClientOptionChanged and Telnet.ServerOptionChanged events, encapsulating the changed option (accessable via the OptionEventArgs.Option property) for which the event was raised.

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

OptionEventArgs Members | Dart.PowerTCP.Telnet Namespace


OptionEventArgs Members

OptionEventArgs overview

Public Instance Properties

Option Represents the option that has changed in an OptionChanged event.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

See Also

OptionEventArgs Class | Dart.PowerTCP.Telnet Namespace


OptionEventArgs Properties

The properties of the OptionEventArgs class are listed below. For a complete list of OptionEventArgs class members, see the OptionEventArgs Members topic.

Public Instance Properties

Option Represents the option that has changed in an OptionChanged event.

See Also

OptionEventArgs Class | Dart.PowerTCP.Telnet Namespace


OptionEventArgs.Option Property

Represents the option that has changed in an OptionChanged event.

[Visual Basic]
Public ReadOnly Property Option As Option
[C#]
public Option Option {get;}

Property Value

An Option object encapsulating the option that has changed.

Remarks

This property is an Option object, encapsulating the Option for which the OptionChanged event was raised.

See Also

OptionEventArgs Class | Dart.PowerTCP.Telnet Namespace


OptionEventHandler Delegate

Represents the method (event handler) that is raised when an option value is changed.

[Visual Basic]
Public Delegate Sub OptionEventHandler( _
ByVal sender As Object, _
ByVal e As OptionEventArgs _
)
[C#]
public delegate void OptionEventHandler(
object sender,
OptionEventArgs e
);

Remarks

As Microsoft describes in their MSDN documentation, the event model in the .NET Framework is based on having an event delegate that connects an event with its handler. To raise an event, two elements are needed:

  • A class that holds the event data. This class must derive from the base class EventArgs.
  • A delegate that points to a method that provides the response to the event.

When the Telnet.ClientOptionChanged or Telnet.ServerOptionChanged event is raised, the class that holds the event data is the OptionEventArgs class. A method must be created with the same signature as the delegate. In this example that would mean a method would have to be defined to accept two arguments (an object and an OptionEventArgs) and return void. Once this has been done, the delegate must be "connected" to the handling event. This is done by adding an instance of the delegate to the event.

For more information about event handler delegates, see the Using Events in PowerTCP topic.

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

Dart.PowerTCP.Telnet Namespace


OptionState Enumeration

Enumerates the current state of an Option object.

[Visual Basic]
Public Enum OptionState
[C#]
public enum OptionState

Remarks

This enumeration enables access to the current state of an option.

Example

[Visual Basic, C#] The following example demonstrates customizing the default option negotiation sequence.

[Visual Basic]
' Cause the client to refuse the TerminalType option if offered by the server
Telnet1.ClientOptions.Remove(Telnet1.ClientOptions(OptionCode.TerminalType))

' Request that server enable the Echo option
Telnet1.ServerOptions.Add(New Option(OptionCode.Echo))

' ReceiveTimeout must be set to a positive value before using the Login method.
Telnet1.ReceiveTimeout = 3000

' Connect and login to the Telnet server
Telnet1.Login("myserver", "myusername", "mypassword", "$")

' What is the result of option negotiation?
Dim o as Option
For Each o in Telnet1.ClientOptions
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
Next

For Each o in Telnet1.ServerOptions
    Debug.WriteLine("Code: " + o.Code)
    Debug.WriteLine("State: " + o.State)
Next
[C#]
// Cause the client to refuse the TerminalType option if offered by the server
telnet1.ClientOptions.Remove(telnet1.ClientOptions[OptionCode.TerminalType]);

// Request that server enable the Echo option
telnet1.ServerOptions.Add(new Option(OptionCode.Echo));

// Connect and login to the Telnet server
telnet1.Login("myserver", "myusername", "mypassword", "$");

// What is the result of option negotiation?
foreach(Option o in telnet1.ClientOptions)
{
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
}
foreach(Option o in telnet1.ClientOptions)
{
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Members

Member Name | Description
Off | Option is not desired or has been actively refused (a Wont or Dont was sent).
RequestOff | Option is not desired, and indicates a Wont or Dont command is sent when option negotiation occurs.
RequestOn | Option is desired, and indicates a Will or Do command is sent when option negotiation occurs.
Waiting | Option is desired, and indicates a command has been sent, but no reply has been received.
Allow | Option is allowed if the remote host desires it, but the Telnet control will not initiate the option negotiation
On | Option is desired and the remote host has agreed to it (a Will and a matching Do was sent).

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

Dart.PowerTCP.Telnet Namespace


PipeStream Class

Represents a stream that wraps an internal stream.

For a list of all members of this type, see PipeStream Members.

System.Object
MarshalByRefObject
Stream
EnhancedStream
PipeStream

[Visual Basic]
Public Class PipeStream
Inherits EnhancedStream
[C#]
public class PipeStream : EnhancedStream

Remarks

PipeStream wraps a stream that is filtered or encoded/decoded in some fashion, calling its methods and properties internally.

PipeStream provides the capability to perform buffered reads/writes. Typically, derived classes would perform a transformation (filtering/encoding) to the data passing through it.

PipeStream does not support seeking\.

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

PipeStream Members | Dart.PowerTCP.Telnet Namespace


PipeStream Members

PipeStream overview

Public Instance Constructors

PipeStream Overloaded. Initializes a new instance of the PipeStream class.

Public Instance Properties

CanRead | Gets a value indicating whether the current Stream supports reading.
CanSeek (inherited from EnhancedStream) | Gets a value indicating whether the current stream supports seeking.
CanWrite (inherited from EnhancedStream) | Gets a value indicating whether the current stream supports writing.
Charset (inherited from EnhancedStream) | Gets and sets the character set used for string/byte array conversions.
CoreStream | The internal stream to which all buffered reads/writes are being made.
Encoding (inherited from EnhancedStream) | Gets or sets the type of encoding to use.
Length | Gets the length in bytes of the stream.
Position | Gets or sets the position within the current stream

Public Instance Methods

BeginRead (inherited from Stream) | Begins an asynchronous read operation.
BeginWrite (inherited from Stream) | Begins an asynchronous write operation.
Close (inherited from Stream) | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from EnhancedStream) | Overloaded. Releases all resources associated with the object.
EndRead (inherited from Stream) | Waits for the pending asynchronous read to complete.
EndWrite (inherited from Stream) | Ends an asynchronous write operation.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Flush | Updates the underlying data source or repository with the current state of the buffer and then clears the buffer.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Read | Overloaded. Read data from the Stream.
Read (inherited from EnhancedStream) | Overloaded. When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
ReadByte (inherited from Stream) | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
Save (inherited from EnhancedStream) | Overloaded. Saves the data in the stream to the file specified by fileName.
Seek (inherited from EnhancedStream) | Sets the position within the current Stream to the specified value. Always throws a NotSupportedException.
SetLength (inherited from EnhancedStream) | Sets the length of the current Stream to the specified value. Always throws a NotSupportedException.
ToArray (inherited from EnhancedStream) | Returns the byte array representation of the Stream data.
ToString (inherited from EnhancedStream) | Returns the string representation of the Stream data.
Write | Overloaded. Writes data to the stream.
Write (inherited from EnhancedStream) | Overloaded. When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
WriteByte (inherited from Stream) | Writes a byte to the current position in the stream and advances the position within the stream by one byte.
WriteTo (inherited from EnhancedStream) | Overloaded. Writes all of the data contained in this Stream to a destination Stream.

Explicit Interface Implementations

IDisposable.Dispose (inherited from Stream)

See Also

PipeStream Class | Dart.PowerTCP.Telnet Namespace


PipeStream Constructor

Creates a new instance of PipeStream.

Overload List

Creates a new instance of PipeStream.

public PipeStream();

Creates a new instance of PipeStream.

public PipeStream(Stream);

Creates a new instance of PipeStream.

public PipeStream(Stream,Encoding);

See Also

PipeStream Class | Dart.PowerTCP.Telnet Namespace


PipeStream Constructor (Stream)

Creates a new instance of PipeStream.

[Visual Basic]
Overloads Public Sub New( _
ByVal coreStream As Stream _
)
[C#]
public PipeStream(
Stream coreStream
);

Parameters

coreStream
The Stream object to set as PipeStream.CoreStream.

Remarks

The default constructor creates a new instance of PipeStream, with PipeStream.CoreStream initialized to the Stream passed in as coreStream.

See Also

PipeStream Class | Dart.PowerTCP.Telnet Namespace | PipeStream Constructor Overload List


PipeStream Constructor (Stream, Encoding)

Creates a new instance of PipeStream.

[Visual Basic]
Overloads Public Sub New( _
ByVal coreStream As Stream, _
ByVal encoding As Encoding _
)
[C#]
public PipeStream(
Stream coreStream,
Encoding encoding
);

Parameters

coreStream
The Stream object to set as PipeStream.CoreStream.
encoding
The Encoding type to use for data transformations.

Remarks

The default constructor creates a new instance of PipeStream, with PipeStream.CoreStream initialized to the Stream passed in as coreStream.

See Also

PipeStream Class | Dart.PowerTCP.Telnet Namespace | PipeStream Constructor Overload List


PipeStream Constructor ()

Creates a new instance of PipeStream.

[Visual Basic]
Overloads Public Sub New()
[C#]
public PipeStream();

Remarks

This constructor is used by derived objects, which must set coreStream.

See Also

PipeStream Class | Dart.PowerTCP.Telnet Namespace | PipeStream Constructor Overload List


PipeStream Properties

The properties of the PipeStream class are listed below. For a complete list of PipeStream class members, see the PipeStream Members topic.

Public Instance Properties

CanRead | Gets a value indicating whether the current Stream supports reading.
CanSeek (inherited from EnhancedStream) | Gets a value indicating whether the current stream supports seeking.
CanWrite (inherited from EnhancedStream) | Gets a value indicating whether the current stream supports writing.
Charset (inherited from EnhancedStream) | Gets and sets the character set used for string/byte array conversions.
CoreStream | The internal stream to which all buffered reads/writes are being made.
Encoding (inherited from EnhancedStream) | Gets or sets the type of encoding to use.
Length | Gets the length in bytes of the stream.
Position | Gets or sets the position within the current stream

See Also

PipeStream Class | Dart.PowerTCP.Telnet Namespace


PipeStream.CanRead Property

Gets a value indicating whether the current Stream supports reading.

[Visual Basic]
Overrides Public ReadOnly Property CanRead As Boolean
[C#]
public override bool CanRead {get;}

Property Value

true if reading is currently allowed, and false if not.

Remarks

If Position < Length, this property returns true to indicate bytes are available to be read, otherwise false.

See Also

PipeStream Class | Dart.PowerTCP.Telnet Namespace


PipeStream.CoreStream Property

The internal stream to which all buffered reads/writes are being made.

[Visual Basic]
Public ReadOnly Property CoreStream As Stream
[C#]
public System.IO.Stream CoreStream {get;}

Remarks

This property returns the internal stream to which all buffered reads/writes are being made.

See Also

PipeStream Class | Dart.PowerTCP.Telnet Namespace


PipeStream.Length Property

Gets the length in bytes of the stream.

[Visual Basic]
Overrides Public ReadOnly Property Length As Long
[C#]
public override long Length {get;}

Remarks

Returns PipeStream.CoreStream.Length if not writing, and PipeStream.Position, if writing.

See Also

PipeStream Class | Dart.PowerTCP.Telnet Namespace


PipeStream.Position Property

Gets or sets the position within the current stream

[Visual Basic]
Overrides Public Property Position As Long
[C#]
public override long Position {get; set;}

Remarks

Returns PipeStream.CoreStream.Position if not writing, and the amount written to the stream, if writing. Attempting to set this property returns an InvalidOperationException unless it is set to 0, in which case the position of the PipeStream.CoreStream.Position will be set to 0, and this object is ready for reading.

See Also

PipeStream Class | Dart.PowerTCP.Telnet Namespace


PipeStream Methods

The methods of the PipeStream class are listed below. For a complete list of PipeStream class members, see the PipeStream Members topic.

Public Instance Methods

BeginRead (inherited from Stream) | Begins an asynchronous read operation.
BeginWrite (inherited from Stream) | Begins an asynchronous write operation.
Close (inherited from Stream) | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from EnhancedStream) | Overloaded. Releases all resources associated with the object.
EndRead (inherited from Stream) | Waits for the pending asynchronous read to complete.
EndWrite (inherited from Stream) | Ends an asynchronous write operation.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Flush | Updates the underlying data source or repository with the current state of the buffer and then clears the buffer.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Read | Overloaded. Read data from the Stream.
Read (inherited from EnhancedStream) | Overloaded. When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
ReadByte (inherited from Stream) | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
Save (inherited from EnhancedStream) | Overloaded. Saves the data in the stream to the file specified by fileName.
Seek (inherited from EnhancedStream) | Sets the position within the current Stream to the specified value. Always throws a NotSupportedException.
SetLength (inherited from EnhancedStream) | Sets the length of the current Stream to the specified value. Always throws a NotSupportedException.
ToArray (inherited from EnhancedStream) | Returns the byte array representation of the Stream data.
ToString (inherited from EnhancedStream) | Returns the string representation of the Stream data.
Write | Overloaded. Writes data to the stream.
Write (inherited from EnhancedStream) | Overloaded. When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
WriteByte (inherited from Stream) | Writes a byte to the current position in the stream and advances the position within the stream by one byte.
WriteTo (inherited from EnhancedStream) | Overloaded. Writes all of the data contained in this Stream to a destination Stream.

Explicit Interface Implementations

IDisposable.Dispose (inherited from Stream)

See Also

PipeStream Class | Dart.PowerTCP.Telnet Namespace


PipeStream.Flush Method

Updates the underlying data source or repository with the current state of the buffer and then clears the buffer.

[Visual Basic]
Overrides Public Sub Flush()
[C#]
public override void Flush();

Remarks

If the Stream contains any internal Streams as members, this method will also cause the Flush method of all internal Streams.

This method MUST be called when writing is complete for operations to operate properly.

Exceptions

Exception Type | Condition
IOException | An I/O error occurs.
ObjectDisposedException | The Stream is closed.

See Also

PipeStream Class | Dart.PowerTCP.Telnet Namespace


Read Method

PowerTCP Telnet for .NET

PipeStream.Read Method

Read data from the Stream.

Overload List

Inherited from EnhancedStream.

public int Read(byte[]);

Read data from the Stream.

public override int Read(byte[],int,int);

See Also

PipeStream Class | Dart.PowerTCP.Telnet Namespace


PipeStream.Read Method (Byte[], Int32, Int32)

Read data from the Stream.

[Visual Basic]
Overrides Overloads Public Function Read( _
ByVal buffer As Byte(), _
ByVal offset As Integer, _
ByVal count As Integer _
) As Integer
[C#]
public override int Read(
byte[] buffer,
int offset,
int count
);

Parameters

buffer
The storage location for the received data.
offset
The zero-based position in the buffer at which to store the received data.
count
The maximum number of bytes to read.

Return Value

The total number of bytes read into the buffer.

Remarks

This method actually calls PipeStream.CoreStream.Read, passing the data "through" the PipeStream and into buffer.

Exceptions

Exception Type | Condition
IOException | Thrown when the Stream is not readable.
ArgumentNullException | Thrown when the buffer or callback is null.
ArgumentOutOfRangeException | Thrown when the offset is less than zero or when count is less than or equal to zero.
ArgumentException | Thrown when the (offset + count) > buffer.Length.

See Also

PipeStream Class | Dart.PowerTCP.Telnet Namespace | PipeStream.Read Overload List


Write Method

PowerTCP Telnet for .NET

PipeStream.Write Method

Writes data to the stream.

Overload List

Inherited from EnhancedStream.

public void Write(byte[]);

Writes data to the stream.

public override void Write(byte[],int,int);

See Also

PipeStream Class | Dart.PowerTCP.Telnet Namespace


PipeStream.Write Method (Byte[], Int32, Int32)

Writes data to the stream.

[Visual Basic]
Overrides Overloads Public Sub Write( _
ByVal buffer As Byte(), _
ByVal offset As Integer, _
ByVal count As Integer _
)
[C#]
public override void Write(
byte[] buffer,
int offset,
int count
);

Parameters

buffer
The storage location for the written data.
offset
The zero-based position in the buffer from which to begin writing from.
count
The exact number of bytes to write.

Remarks

This method actually calls PipeStream.CoreStream.Write, passing the data "through" the PipeStream and into PipeStream.CoreStream.

Exceptions

Exception Type | Condition
IOException | Thrown when the Stream is not writeable.
ArgumentNullException | Thrown when the buffer is null.
ArgumentOutOfRangeException | Thrown when the offset is less than zero or when count is less than or equal to zero.
ArgumentException | Thrown when the (offset + count) > buffer.Length.

See Also

PipeStream Class | Dart.PowerTCP.Telnet Namespace | PipeStream.Write Overload List


ProtocolException Class

Used to throw protocol exceptions for upper-layer protocols like FTP, SMTP and POP3.

For a list of all members of this type, see ProtocolException Members.

System.Object
Exception
ApplicationException
ProtocolException

[Visual Basic]
Public Class ProtocolException
Inherits ApplicationException
[C#]
public class ProtocolException : ApplicationException

Remarks

This exception is thrown when a server response is negative. For example, if the server returned "500" (indicating a syntax error) as response to a command being sent, a ProtocolException would be thrown.

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

ProtocolException Members | Dart.PowerTCP.Telnet Namespace


ProtocolException Members

ProtocolException overview

Public Instance Constructors

ProtocolException Overloaded. Initializes a new instance of the ProtocolException class.

Public Instance Properties

HelpLink (inherited from Exception) | Gets or sets a link to the help file associated with this exception.
InnerException (inherited from Exception) | Gets the Exception instance that caused the current exception.
Message (inherited from Exception) | Gets a message that describes the current exception.
Source (inherited from Exception) | Gets or sets the name of the application or the object that causes the error.
StackTrace (inherited from Exception) | Gets a string representation of the frames on the call stack at the time the current exception was thrown.
TargetSite (inherited from Exception) | Gets the method that throws the current exception.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetBaseException (inherited from Exception) | When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetObjectData (inherited from Exception) | When overridden in a derived class, sets the SerializationInfo with information about the exception.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Exception) | Creates and returns a string representation of the current exception.

See Also

ProtocolException Class | Dart.PowerTCP.Telnet Namespace


ProtocolException Constructor

Initializes a new instance of the ProtocolException class.

Overload List

Initializes a new instance of the ProtocolException class.

public ProtocolException();

Initializes a new instance of the ProtocolException class.

public ProtocolException(string);

Initializes a new instance of the ProtocolException class.

public ProtocolException(string,Exception);

See Also

ProtocolException Class | Dart.PowerTCP.Telnet Namespace


ProtocolException Constructor ()

Initializes a new instance of the ProtocolException class.

[Visual Basic]
Overloads Public Sub New()
[C#]
public ProtocolException();

See Also

ProtocolException Class | Dart.PowerTCP.Telnet Namespace | ProtocolException Constructor Overload List


ProtocolException Constructor (String)

Initializes a new instance of the ProtocolException class.

[Visual Basic]
Overloads Public Sub New( _
ByVal message As String _
)
[C#]
public ProtocolException(
string message
);

See Also

ProtocolException Class | Dart.PowerTCP.Telnet Namespace | ProtocolException Constructor Overload List


ProtocolException Constructor (String, Exception)

Initializes a new instance of the ProtocolException class.

[Visual Basic]
Overloads Public Sub New( _
ByVal message As String, _
ByVal e As Exception _
)
[C#]
public ProtocolException(
string message,
Exception e
);

See Also

ProtocolException Class | Dart.PowerTCP.Telnet Namespace | ProtocolException Constructor Overload List


Proxy Class

Provides an easy way to manage communication with proxy servers

For a list of all members of this type, see Proxy Members.

System.Object
Proxy

[Visual Basic]
Public Class Proxy
[C#]
public class Proxy

Remarks

The Proxy class provides extensive native support for proxy servers. Simply set the appropriate properties of the Proxy class and proxy communication occurs transparently.

When using PowerTCP components that use the Tcp component for the underlying connection, you can set the Proxy properties by using the object.Connection property, which exposes the Tcp component. When using the Tcp component, simple set the Tcp.Proxy property.

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

Proxy Members | Dart.PowerTCP.Telnet Namespace


Proxy Members

Proxy overview

Public Instance Constructors

Proxy Constructor Initializes a new instance of the Proxy class.

Public Instance Properties

Password | Password to use when authenticating to a proxy.
Server | Get or set a value which specifies the proxy server to use.
ServerPort | Port to use when connecting to a proxy server.
Type | Type of proxy.
Username | User name to use when authenticating to a proxy.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

See Also

Proxy Class | Dart.PowerTCP.Telnet Namespace


Proxy Constructor

Initializes a new instance of the Proxy class.

[Visual Basic]
Public Sub New()
[C#]
public Proxy();

Remarks

The default constructor initializes a new instance of the Proxy class.

See Also

Proxy Class | Dart.PowerTCP.Telnet Namespace


Proxy Properties

The properties of the Proxy class are listed below. For a complete list of Proxy class members, see the Proxy Members topic.

Public Instance Properties

Password | Password to use when authenticating to a proxy.
Server | Get or set a value which specifies the proxy server to use.
ServerPort | Port to use when connecting to a proxy server.
Type | Type of proxy.
Username | User name to use when authenticating to a proxy.

See Also

Proxy Class | Dart.PowerTCP.Telnet Namespace


Proxy.Password Property

Password to use when authenticating to a proxy.

[Visual Basic]
Public Property Password As String
[C#]
public string Password {get; set;}

Property Value

A string value representing the password used to access the a proxy.

Remarks

Specifies the password to use for authentication on some proxies.

See Also

Proxy Class | Dart.PowerTCP.Telnet Namespace


Proxy.Server Property

Get or set a value which specifies the proxy server to use.

[Visual Basic]
Public Property Server As String
[C#]
public string Server {get; set;}

Property Value

A string representing the proxy server to use.

Remarks

Specifies the hostname of the proxy server. Specify the server either in dot notation ("111.111.111.111") or by host name ("myserver").

See Also

Proxy Class | Dart.PowerTCP.Telnet Namespace


Proxy.ServerPort Property

Port to use when connecting to a proxy server.

[Visual Basic]
Public Property ServerPort As Integer
[C#]
public int ServerPort {get; set;}

Property Value

An integer value representing a proxy port to connect to.

Remarks

Specifies the port to use when connecting to the proxy server.

See Also

Proxy Class | Dart.PowerTCP.Telnet Namespace


Proxy.Type Property

Type of proxy.

[Visual Basic]
Public Property Type As ProxyType
[C#]
public ProxyType Type {get; set;}

Property Value

One of the ProxyType values.

Remarks

Specifies the type of proxy used.

See Also

Proxy Class | Dart.PowerTCP.Telnet Namespace


Proxy.Username Property

User name to use when authenticating to a proxy.

[Visual Basic]
Public Property Username As String
[C#]
public string Username {get; set;}

Property Value

A string value representing the user name used to access a proxy.

Remarks

Specifies the username to use for authentication on some proxies.

See Also

Proxy Class | Dart.PowerTCP.Telnet Namespace


ProxyType Enumeration

Enumerates the supported proxy types.

[Visual Basic]
Public Enum ProxyType
[C#]
public enum ProxyType

Remarks

This enumeration is used by the Proxy property.

Set the Proxy.Type property to the proper ProxyType of your proxy server before calling any method that requires communication with the server.

Members

Member Name | Description
None | No proxy server is used.
Socks4 | SOCKS v4 proxy.
Socks5 | SOCKS v5 proxy.

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

Dart.PowerTCP.Telnet Namespace


Rexec Class

The Rexec component enables use of the remote execution protocol within any .NET application.

For a list of all members of this type, see Rexec Members.

System.Object
MarshalByRefObject
Component
Rexec

[Visual Basic]
Public Class Rexec
Inherits Component
[C#]
public class Rexec : Component

Remarks

Use the Rexec component to execute a command on a remote host (typically a UNIX host). To use the Rexec component, call Rexec.Execute, passing in the appropriate parameters. A Segment object is returned, encapsulating the response from the server. Behind-the-scenes the Rexec component will connect to the remote host, login, send the command, receive the response, and logout.

Rexec and Rsh do the same thing using different authentication techniques. Whereas Rsh requires static information be added to .rhosts and/or equiv, Rexec simply uses dynamic username/password information for authentication.

Example

[Visual Basic, C#] The following example demonstrates simple use of the Rexec component.

[Visual Basic]
' Execute a command
Dim Seg As Segment = Rexec1.Execute("myserver", "myuser", "mypass", "pwd")

' Display the result
Debug.WriteLine("Current directory: " + Seg.ToString())
[C#]
// Execute a command
Segment seg = rexec1.Execute("myserver", "myuser", "mypass", "pwd");

// Display the result
Debug.WriteLine("Current directory: " + seg.ToString());

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

Rexec Members | Dart.PowerTCP.Telnet Namespace


Rexec Members

Rexec overview

Public Instance Constructors

Rexec Overloaded. Initializes a new instance of the Rexec class.

Public Instance Properties

Connection |
Container (inherited from Component) | Gets the IContainer that contains the Component.
DoEvents | Gets or sets a value that controls the processing of events during blocking method calls.
Editor | In Visual Studio.NET, displays an interactive form to use to test real time protocol operations.
Site (inherited from Component) | Gets or sets the ISite of the Component.
SynchronizingObject |

Public Instance Methods

BeginExecute | Overloaded. Begin to asynchronously execute a command on a remote host.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from Component) | Releases all resources used by the Component.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Execute | Overloaded. Execute a command on a remote host.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
ToString (inherited from Component) |

Public Instance Events

Disposed (inherited from Component) | Adds an event handler to listen to the Disposed event on the component.
EndExecute | Raised when the Rexec.BeginExecute request completes.

See Also

Rexec Class | Dart.PowerTCP.Telnet Namespace


Rexec Constructor

Create a new instance of the Rexec component.

Overload List

Create a new instance of the Rexec component.

public Rexec();

Create a new instance of the Rexec component.

public Rexec(IContainer);

See Also

Rexec Class | Dart.PowerTCP.Telnet Namespace


Rexec Constructor (IContainer)

Create a new instance of the Rexec component.

[Visual Basic]
Overloads Public Sub New( _
ByVal container As IContainer _
)
[C#]
public Rexec(
IContainer container
);

Remarks

This constructor initializes a new instance of the Rexec component, adding it to the specified IContainer container.

To create an instance of the Rexec component using Visual Studio.NET, simply add the Rexec component to the form and the object will automatically be created and initialized. If working out of the Visual Studio.NET environment (or using the Rexec component as a reference), the Rexec component will have to be explicitly created and initialized.

The following table shows initial property values for an instance of Rexec.

Property | Initial Value
Rexec.Connection | Tcp object
Rexec.DoEvents | True

See Also

Rexec Class | Dart.PowerTCP.Telnet Namespace | Rexec Constructor Overload List


Rexec Constructor ()

Create a new instance of the Rexec component.

[Visual Basic]
Overloads Public Sub New()
[C#]
public Rexec();

Remarks

The default constructor creates a new instance of Rexec.

To create an instance of the Rexec component using Visual Studio.NET, simply add the Rexec component to the form and the object will automatically be created and initialized. If working out of the Visual Studio.NET environment (or using the Rexec component as a reference), the Rexec component will have to be explicitly created and initialized.

The following table shows initial property values for an instance of Rexec.

Property | Initial Value
Rexec.Connection | Tcp object
Rexec.DoEvents | True

See Also

Rexec Class | Dart.PowerTCP.Telnet Namespace | Rexec Constructor Overload List


Rexec Properties

The properties of the Rexec class are listed below. For a complete list of Rexec class members, see the Rexec Members topic.

Public Instance Properties

Connection |
Container (inherited from Component) | Gets the IContainer that contains the Component.
DoEvents | Gets or sets a value that controls the processing of events during blocking method calls.
Editor | In Visual Studio.NET, displays an interactive form to use to test real time protocol operations.
Site (inherited from Component) | Gets or sets the ISite of the Component.
SynchronizingObject |

See Also

Rexec Class | Dart.PowerTCP.Telnet Namespace


Rexec.Connection Property

[Visual Basic]
Public ReadOnly Property Connection As Tcp
[C#]
public Tcp Connection {get;}

See Also

Rexec Class | Dart.PowerTCP.Telnet Namespace


Rexec.DoEvents Property

Gets or sets a value that controls the processing of events during blocking method calls.

[Visual Basic]
Public Property DoEvents As Boolean
[C#]
public bool DoEvents {get; set;}

Property Value

true if user-interface events should be processed during synchronous method calls; otherwise, false. The default value is true.

Remarks

When performing a synchronous (blocking) method, PowerTCP will process user-interface events (such as window painting) if this property is set to true AND the current thread has an event message queue. If no message queue is present (such as on an ASP page or under any worker thread), the value of this property has no effect. This property is used only for synchronous methods. Object.DoEvents is not needed if using asynchronous methods because the asynchronous method will execute on a different thread, allowing the UI thread to continue working unblocked.

For example, this property is beneficial when an interactive application is being used and the user may want to abort a currently processing operation by clicking an "Abort" button. If Object.DoEvents is set to false, this will not be possible. Set the Object.DoEvents property to true and the application will respond to other events (such as button clicks) during synchronous operations.

See Also

Rexec Class | Dart.PowerTCP.Telnet Namespace


Rexec.Editor Property

In Visual Studio.NET, displays an interactive form to use to test real time protocol operations.

[Visual Basic]
Public Property Editor As Object
[C#]
public object Editor {get; set;}

Property Value

An EditorForm to use in VS.NET to test protocol operations.

Remarks

This property can only be used by clicking this property in the Properties Window in Visual Studio.NET. This will open an application which can be used to test protocol operation. The EditorForm will not be available if the PowerTCP component is being used as a reference.

The Object.Editor property can ONLY be used at design time in the Visual Studio.NET environment.

See Also

Rexec Class | Dart.PowerTCP.Telnet Namespace


Rexec Methods

The methods of the Rexec class are listed below. For a complete list of Rexec class members, see the Rexec Members topic.

Public Instance Methods

BeginExecute | Overloaded. Begin to asynchronously execute a command on a remote host.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from Component) | Releases all resources used by the Component.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Execute | Overloaded. Execute a command on a remote host.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
ToString (inherited from Component) |

See Also

Rexec Class | Dart.PowerTCP.Telnet Namespace


BeginExecute Method

PowerTCP Telnet for .NET

Rexec.BeginExecute Method

Begin to asynchronously execute a command on a remote host, specifying the remote port to use.

Overload List

Begin to asynchronously execute a command on a remote host, specifying the remote port to use.

public IAsyncResult BeginExecute(string,string,string,string,int,object);

Begin to asynchronously execute a command on a remote host.

public IAsyncResult BeginExecute(string,string,string,string,object);

See Also

Rexec Class | Dart.PowerTCP.Telnet Namespace


Rexec.BeginExecute Method (String, String, String, String, Int32, Object)

Begin to asynchronously execute a command on a remote host, specifying the remote port to use.

[Visual Basic]
Overloads Public Function BeginExecute( _
ByVal server As String, _
ByVal username As String, _
ByVal password As String, _
ByVal command As String, _
ByVal serverPort As Integer, _
ByVal state As Object _
) As IAsyncResult
[C#]
public IAsyncResult BeginExecute(
string server,
string username,
string password,
string command,
int serverPort,
object state
);

Parameters

server
The remote host to execute the command on.
username
The login name of the user account.
password
The password of the user account.
command
The command to execute.
serverPort
The remote port to connect to.
state
User state information.

Return Value

An IAsyncResult that represents the asynchronous operation, which could still be pending.

Remarks

This method attempts to connect to the remote host specified by server and serverPort, then authenticates using username and pass, executes the command specified by command, then logs out. Upon completion, the Rexec.EndExecute is raised. A SegmentEventArgs object is passed into the Rexec.EndExecute event and encapsulates the response from the server.

When the server responds to a REXEC command, the first byte received indicates success/failure of the command; 0 for success and 1 for failure. When using the Rexec component, if the first byte is a 1 (meaning failure) a ProtocolException is thrown. ProtocolException.Message will contain the response from the server minus the first byte.

Exceptions

Exception Type | Condition
InvalidOperationException | BeginXXX method used without providing an EndXXX event handler.

Example

[Visual Basic, C#] The following example demonstrates simple use of the Rexec component to execute a command asynchronously, using a non-standard port.

[Visual Basic]
   ' Execute a command. When completed the Rexec.EndExecute event will be raised.
   Rexec1.BeginExecute("myserver", "myuser", "mypass", "pwd", 5000, Nothing)

Private Sub Rexec1_EndExecute(ByVal sender As Object, ByVal e As Dart.PowerTCP.Telnet.SegmentEventArgs) Handles Rexec1.EndExecute
    Debug.WriteLine("Current directory: " + e.Segment.ToString())
End Sub
[C#]
   ' Execute a command. When completed the Rexec.EndExecute event will be raised.
   rexec1.BeginExecute("myserver", "myuser", "mypass", "pwd", 5000, null);

private void rexec1_EndExecute(object sender, Dart.PowerTCP.Telnet.SegmentEventArgs e)
{
   Debug.WriteLine("Current directory: " + e.Segment.ToString());
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Rexec Class | Dart.PowerTCP.Telnet Namespace | Rexec.BeginExecute Overload List


Rexec.BeginExecute Method (String, String, String, String, Object)

Begin to asynchronously execute a command on a remote host.

[Visual Basic]
Overloads Public Function BeginExecute( _
ByVal server As String, _
ByVal username As String, _
ByVal password As String, _
ByVal command As String, _
ByVal state As Object _
) As IAsyncResult
[C#]
public IAsyncResult BeginExecute(
string server,
string username,
string password,
string command,
object state
);

Parameters

server
The remote host to execute the command on.
username
The login name of the user account.
password
The password of the user account.
command
The command to execute.
state
User state information.

Return Value

An IAsyncResult that represents the asynchronous operation, which could still be pending.

Remarks

This method attempts to connect to the remote host specified by server and the well-known port of 512, then authenticates using username and pass, executes the command specified by command, then logs out. Upon completion, the Rexec.EndExecute is raised. A SegmentEventArgs object is passed into the Rexec.EndExecute event and encapsulates the response from the server.

When the server responds to a REXEC command, the first byte received indicates success/failure of the command; 0 for success and 1 for failure. When using the Rexec component, if the first byte is a 1 (meaning failure) a ProtocolException is thrown. ProtocolException.Message will contain the response from the server minus the first byte.

Exceptions

Exception Type | Condition
InvalidOperationException | BeginXXX method used without providing an EndXXX event handler.

Example

[Visual Basic, C#] The following example demonstrates simple use of the Rexec component to execute a command asynchronously.

[Visual Basic]
   ' Execute a command. When completed the Rexec.EndExecute event will be raised.
   Rexec1.BeginExecute("myserver", "myuser", "mypass", "pwd", Nothing)

Private Sub Rexec1_EndExecute(ByVal sender As Object, ByVal e As Dart.PowerTCP.Telnet.SegmentEventArgs) Handles Rexec1.EndExecute
    Debug.WriteLine("Current directory: " + e.Segment.ToString())
End Sub
[C#]
   ' Execute a command. When completed the Rexec.EndExecute event will be raised.
   rexec1.BeginExecute("myserver", "myuser", "mypass", "pwd", null);

private void rexec1_EndExecute(object sender, Dart.PowerTCP.Telnet.SegmentEventArgs e)
{
   Debug.WriteLine("Current directory: " + e.Segment.ToString());
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Rexec Class | Dart.PowerTCP.Telnet Namespace | Rexec.BeginExecute Overload List


Execute Method

PowerTCP Telnet for .NET

Rexec.Execute Method

Execute a command on a remote host.

Overload List

Execute a command on a remote host.

public Segment Execute(string,string,string,string);

Execute a command on a remote host, specifying the remote port to use.

public Segment Execute(string,string,string,string,int);

See Also

Rexec Class | Dart.PowerTCP.Telnet Namespace


Rexec.Execute Method (String, String, String, String)

Execute a command on a remote host.

[Visual Basic]
Overloads Public Function Execute( _
ByVal server As String, _
ByVal username As String, _
ByVal password As String, _
ByVal command As String _
) As Segment
[C#]
public Segment Execute(
string server,
string username,
string password,
string command
);

Parameters

server
The remote host to execute the command on.
username
The login name of the user account.
password
The password of the user account.
command
The command to execute.

Return Value

A Segment object encapsulating the response from the server.

Remarks

This method attempts to connect to the remote host specified by server and the well-known port of 512, then authenticates using username and pass, executes the command specified by command, then logs out. A Segment object is returned from this object, encapsulating the response from the server.

When the server responds to a REXEC command, the first byte received indicates success/failure of the command; 0 for success and 1 for failure. When using the Rexec component, if the first byte is a 1 (meaning failure) a ProtocolException is thrown. ProtocolException.Message will contain the response from the server minus the first byte.

Exceptions

Exception Type | Condition
SocketException | The remote host does not exist or is unreachable.

Example

[Visual Basic, C#] The following example demonstrates simple use of the Rexec component.

[Visual Basic]
' Execute a command
Dim Seg As Segment = Rexec1.Execute("myserver", "myuser", "mypass", "pwd")

' Display the result
Debug.WriteLine("Current directory: " + Seg.ToString())
[C#]
// Execute a command
Segment seg = rexec1.Execute("myserver", "myuser", "mypass", "pwd");

// Display the result
Debug.WriteLine("Current directory: " + seg.ToString());

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Rexec Class | Dart.PowerTCP.Telnet Namespace | Rexec.Execute Overload List


Rexec.Execute Method (String, String, String, String, Int32)

Execute a command on a remote host, specifying the remote port to use.

[Visual Basic]
Overloads Public Function Execute( _
ByVal server As String, _
ByVal username As String, _
ByVal password As String, _
ByVal command As String, _
ByVal serverPort As Integer _
) As Segment
[C#]
public Segment Execute(
string server,
string username,
string password,
string command,
int serverPort
);

Parameters

server
The remote host to execute the command on.
username
The login name of the user account.
password
The password of the user account.
command
The command to execute.
serverPort
The remote port to connect to.

Return Value

A Segment object encapsulating the response from the server.

Remarks

This method attempts to connect to the remote host specified by server and serverPort, then authenticates using username and pass, executes the command specified by command, then logs out. A Segment object is returned from this object, encapsulating the response from the server.

When the server responds to a REXEC command, the first byte received indicates success/failure of the command; 0 for success and 1 for failure. When using the Rexec component, if the first byte is a 1 (meaning failure) a ProtocolException is thrown. ProtocolException.Message will contain the response from the server minus the first byte.

Exceptions

Exception Type | Condition
SocketException | The remote host does not exist or is unreachable.
ProtocolException | Bad response received from server.

Example

[Visual Basic, C#] The following example demonstrates simple use of the Rexec component with a non-standard port.

[Visual Basic]
' Execute a command, using a non-standard port
Dim Seg As Segment = Rexec1.Execute("myserver", "myuser", "mypass", "pwd", 5000)

' Display the result
Debug.WriteLine("Current directory: " + Seg.ToString())
[C#]
// Execute a command, using a non-standard port
Segment seg = rexec1.Execute("myserver", "myuser", "mypass", "pwd", 5000);

// Display the result
Debug.WriteLine("Current directory: " + seg.ToString());

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Rexec Class | Dart.PowerTCP.Telnet Namespace | Rexec.Execute Overload List


Rexec Events

The events of the Rexec class are listed below. For a complete list of Rexec class members, see the Rexec Members topic.

Public Instance Events

Disposed (inherited from Component) | Adds an event handler to listen to the Disposed event on the component.
EndExecute | Raised when the Rexec.BeginExecute request completes.

See Also

Rexec Class | Dart.PowerTCP.Telnet Namespace


Rexec.EndExecute Event

Raised when the Rexec.BeginExecute request completes.

[Visual Basic]
Public Event EndExecute As SegmentEventHandler
[C#]
public event SegmentEventHandler EndExecute;

Event Data

The event handler receives an argument of type SegmentEventArgs containing data related to this event. The following SegmentEventArgs properties provide information specific to this event.

Property | Description
Exception | Gets any exception which occurred during the asynchronous operation.
Segment | The Segment object referencing the data that was sent or received.
State | Gets the object that was included as part of the associated method call.

Remarks

This event is raised when the asynchronous operation started by Rexec.BeginExecute completes. A SegmentEventArgs object is passed into the event, containing information about the event, such as the response from the remote host.

If any errors occurred during the asynchronous operation, they would be returned in the SegmentEventArgs object, check SegmentEventArgs.Exception to check for any exception.

For more information on using events using PowerTCP.NET within the Visual Studio.NET environment, see the topic, "Using Events Within The Visual Studio.NET Environment".

If you are using the Rexec component as a reference, you must create a method to handle the event yourself.

This event MUST be implemented if you are using the Rexec.BeginExecute method. See the topic "Using EndXXX Events" for more information.

Example

[Visual Basic, C#] The following example demonstrates simple use of the Rexec component to execute a command asynchronously.

[Visual Basic]
   ' Execute a command. When completed the Rexec.EndExecute event will be raised.
   Rexec1.BeginExecute("myserver", "myuser", "mypass", "pwd", Nothing)

Private Sub Rexec1_EndExecute(ByVal sender As Object, ByVal e As Dart.PowerTCP.Telnet.SegmentEventArgs) Handles Rexec1.EndExecute
    Debug.WriteLine("Current directory: " + e.Segment.ToString())
End Sub
[C#]
   ' Execute a command. When completed the Rexec.EndExecute event will be raised.
   rexec1.BeginExecute("myserver", "myuser", "mypass", "pwd", null);

private void rexec1_EndExecute(object sender, Dart.PowerTCP.Telnet.SegmentEventArgs e)
{
   Debug.WriteLine("Current directory: " + e.Segment.ToString());
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Rexec Class | Dart.PowerTCP.Telnet Namespace


Rlogin Class

The Rlogin component enables use of the remote login protocol within any .NET application.

For a list of all members of this type, see Rlogin Members.

System.Object
MarshalByRefObject
Component
Tcp
Rlogin

[Visual Basic]
Public Class Rlogin
Inherits Tcp
[C#]
public class Rlogin : Tcp

Remarks

Use the Rlogin component to login to a remote host (typically a UNIX host). To use the Rlogin component, call Rlogin.Login, passing in the appropriate parameters. Once connected, send commands to the remote host by using Rlogin.Send; receive data from the remote host using Rlogin.Receive.

Rlogin is similar to Telnet but simpler. Rlogin does not support option negotiation as Telnet does but does support the concept of window size. Set the Rlogin.DisplayCharacters and Rlogin.DisplayPixels properties and the appropriate window size response is sent when the server requests this information.

Rlogin requires authorization for the local host running your application. This is done by adding the proper entries to the hosts.equiv or .rhosts files located on the remote host. These files enable logins to be performed from other machines and users. The hosts.equiv file is a system file containing names of remote hosts authorized to execute the remote protocol. If not authorized in this file, the remote host looks for the .rhosts file located in the user's account on the remote host. The .rhosts file contains lines of host names and login names paired together. Your local host with login name is authorized if found in this file. If you are not in the remote hosts .rhosts file, the server will request an interactive login like Telnet.

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

Rlogin Members | Dart.PowerTCP.Telnet Namespace


Rlogin Members

Rlogin overview

Public Instance Constructors

Rlogin Overloaded. Initializes a new instance of the Rlogin class.

Public Instance Properties

AutoReceive (inherited from Tcp) | Gets or sets a value which determines if data is automatically receved.
Available (inherited from Tcp) | Gets the amount of data that has been received from the network and is available to be read.
Charset (inherited from Tcp) | Gets and sets the character set used for string/byte array conversions.
Connected (inherited from Tcp) | Gets the connected state of the connection.
ConnectTimeout (inherited from Tcp) | Gets or sets the number of milliseconds to wait for response from the server when connecting.
Container (inherited from Component) | Gets the IContainer that contains the Component.
DisplayCharacters | Gets or sets character display information.
DisplayPixels | Gets or sets pixel display information.
DoEvents (inherited from Tcp) | Gets or sets a value that controls the processing of events during blocking method calls.
Editor | In Visual Studio.NET, displays an interactive form to use to test real time protocol operations.
KeepAlive (inherited from Tcp) | Gets or sets the value of the socket's KeepAlive option.
LocalEndPoint (inherited from Tcp) | Returns the local address the socket is bound to.
NoDelay (inherited from Tcp) | Gets and sets a value the disables the use of Nagle's algorithm so that data is sent immediately.
OutOfBandInline (inherited from Tcp) | Gets or sets a value that indicates whether out-of-band (urgent) data is read as normal in-line data.
Proxy (inherited from Tcp) | Returns the Proxy instance that controls proxy server use.
ReceiveBufferSize (inherited from Tcp) | Gets and sets the size of the system receive buffer.
ReceiveTimeout (inherited from Tcp) | Gets and sets the number of milliseconds that a Tcp.Receive method will block before throwing a SocketException.
RemoteEndPoint (inherited from Tcp) | Returns the remote address/port the socket is connected to.
ReuseAddress (inherited from Tcp) | Gets or sets a value that typically allows any local port to be specified, even if it is already in use.
SendBufferSize (inherited from Tcp) | Gets and sets the size of the system send buffer.
SendTimeout (inherited from Tcp) | Gets and sets the number of milliseconds that a Tcp.Send method will block before throwing a SocketException.
Site (inherited from Component) | Gets or sets the ISite of the Component.
Socket (inherited from Tcp) | Returns a reference to the System.Net.Sockets.Socket instance being used.
Stream (inherited from Tcp) | Returns a SegmentedStream that can be used for advanced streaming operations on the socket.
SynchronizingObject (inherited from Tcp) | Set this object to automatically control thread marshalling between worker threads and the main UI thread.
Tag (inherited from Tcp) | Gets or sets an object reference that can be used to associate this instance with any other.
TerminalTypeSpeed | Gets or sets terminal type and speed.

Public Instance Methods

BeginConnect | Overloaded. Asynchronously begin to connect to a remote host. Always throws a NotSupportedException.
BeginConnect (inherited from Tcp) | Overloaded. Connect to a server asynchronously, specifying the local interface and a range of local ports to use. The Tcp.EndConnect event is raised when completed.
BeginLogin | Overloaded. Asynchronously begin to login to a remote host.
BeginReceive (inherited from Tcp) | Overloaded. Receive data into your buffer asynchronously specifying a buffer, offset, size and SocketFlags value. The Tcp.EndReceive event is raised when completed.
BeginSend (inherited from Tcp) | Overloaded. Send data from your buffer asynchronously, specifying a buffer, offset, size and SocketFlags value. The Tcp.EndSend event is raised when completed.
Close (inherited from Tcp) | Overloaded. Close the connection.
Connect | Overloaded. Connect to a remote host. Always throws a NotSupportedException.
Connect (inherited from Tcp) | Overloaded. Connect to a host, specifying the local interface and a range of local ports to use.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from Component) | Releases all resources used by the Component.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Login | Overloaded. Login to a remote host.
Receive (inherited from Tcp) | Overloaded. Receive data from the host, specifying a buffer, offset, size and SocketFlags value.
Send (inherited from Tcp) | Overloaded. Send data to the server, specifying a buffer, offset, size and SocketFlags value.
ToString (inherited from Component) |
WaitFor | Reads data from the stream until the specified string is found.

Public Instance Events

ConnectedChanged (inherited from Tcp) | Raised when the value of the Object.Connected property changes.
Disposed (inherited from Component) | Adds an event handler to listen to the Disposed event on the component.
EndConnect (inherited from Tcp) | Raised when the Tcp.BeginConnect request completes.
EndLogin | Raised when the Rlogin.BeginLogin request completes.
EndReceive (inherited from Tcp) | Raised when the Tcp.BeginReceive request completes.
EndSend (inherited from Tcp) | Raised when the Tcp.BeginSend request completes.
RawTrace (inherited from Tcp) | Raised when data has been sent/received.
Trace (inherited from Tcp) | Raised when data has been sent/received.

See Also

Rlogin Class | Dart.PowerTCP.Telnet Namespace


Rlogin Constructor

Create a new instance of the Rlogin component.

Overload List

Create a new instance of the Rlogin component.

public Rlogin();

Create a new instance of the Rlogin component.

public Rlogin(IContainer);

See Also

Rlogin Class | Dart.PowerTCP.Telnet Namespace


Rlogin Constructor (IContainer)

Create a new instance of the Rlogin component.

[Visual Basic]
Overloads Public Sub New( _
ByVal container As IContainer _
)
[C#]
public Rlogin(
IContainer container
);

Remarks

This constructor initializes a new instance of the Telnet component, adding it to the specified IContainer container.

To create an instance of the Rlogin component using Visual Studio.NET, simply add the Rlogin component to the form and the object will automatically be created and initialized. If working out of the Visual Studio.NET environment (or using the Rlogin component as a reference), the Rlogin component will have to be explicitly created and initialized.

The following table shows initial property values for an instance of Rlogin.

Property | Initial Value
Rlogin.AutoReceive | false
Rlogin.Charset | Default system charset (accessible via System.Text.Encoding.Default.BodyName)
Rlogin.DisplayCharacters | System.Drawing.Size object ("72,24")
Rlogin.DisplayPixels | System.Drawing.Size object ("640,480")
Rlogin.DoEvents | true
Rlogin.KeepAlive | false
Rlogin.NoDelay | false
Rlogin.OutOfBandInline | false
Rlogin.ReceiveBufferSize | 8192
Rlogin.ReceiveTimeout | 0
Rlogin.ReuseAddress | false
Rlogin.SendBufferSize | 8192
Rlogin.SendTimeout | 0
Rlogin.TerminalTypeSpeed | "vt320/19200"

See Also

Rlogin Class | Dart.PowerTCP.Telnet Namespace | Rlogin Constructor Overload List


Rlogin Constructor ()

Create a new instance of the Rlogin component.

[Visual Basic]
Overloads Public Sub New()
[C#]
public Rlogin();

Remarks

The default constructor creates a new instance of the Rlogin component.

To create an instance of the Rlogin component using Visual Studio.NET, simply add the Rlogin component to the form and the object will automatically be created and initialized. If working out of the Visual Studio.NET environment (or using the Rlogin component as a reference), the Rlogin component will have to be explicitly created and initialized.

The following table shows initial property values for an instance of Rlogin.

Property | Initial Value
Rlogin.AutoReceive | false
Rlogin.Charset | Default system charset (accessible via System.Text.Encoding.Default.BodyName)
Rlogin.DisplayCharacters | System.Drawing.Size object ("72,24")
Rlogin.DisplayPixels | System.Drawing.Size object ("640,480")
Rlogin.DoEvents | true
Rlogin.KeepAlive | false
Rlogin.NoDelay | false
Rlogin.OutOfBandInline | false
Rlogin.ReceiveBufferSize | 8192
Rlogin.ReceiveTimeout | 0
Rlogin.ReuseAddress | false
Rlogin.SendBufferSize | 8192
Rlogin.SendTimeout | 0
Rlogin.TerminalTypeSpeed | "vt320/19200"

See Also

Rlogin Class | Dart.PowerTCP.Telnet Namespace | Rlogin Constructor Overload List


Rlogin Properties

The properties of the Rlogin class are listed below. For a complete list of Rlogin class members, see the Rlogin Members topic.

Public Instance Properties

AutoReceive (inherited from Tcp) | Gets or sets a value which determines if data is automatically receved.
Available (inherited from Tcp) | Gets the amount of data that has been received from the network and is available to be read.
Charset (inherited from Tcp) | Gets and sets the character set used for string/byte array conversions.
Connected (inherited from Tcp) | Gets the connected state of the connection.
ConnectTimeout (inherited from Tcp) | Gets or sets the number of milliseconds to wait for response from the server when connecting.
Container (inherited from Component) | Gets the IContainer that contains the Component.
DisplayCharacters | Gets or sets character display information.
DisplayPixels | Gets or sets pixel display information.
DoEvents (inherited from Tcp) | Gets or sets a value that controls the processing of events during blocking method calls.
Editor | In Visual Studio.NET, displays an interactive form to use to test real time protocol operations.
KeepAlive (inherited from Tcp) | Gets or sets the value of the socket's KeepAlive option.
LocalEndPoint (inherited from Tcp) | Returns the local address the socket is bound to.
NoDelay (inherited from Tcp) | Gets and sets a value the disables the use of Nagle's algorithm so that data is sent immediately.
OutOfBandInline (inherited from Tcp) | Gets or sets a value that indicates whether out-of-band (urgent) data is read as normal in-line data.
Proxy (inherited from Tcp) | Returns the Proxy instance that controls proxy server use.
ReceiveBufferSize (inherited from Tcp) | Gets and sets the size of the system receive buffer.
ReceiveTimeout (inherited from Tcp) | Gets and sets the number of milliseconds that a Tcp.Receive method will block before throwing a SocketException.
RemoteEndPoint (inherited from Tcp) | Returns the remote address/port the socket is connected to.
ReuseAddress (inherited from Tcp) | Gets or sets a value that typically allows any local port to be specified, even if it is already in use.
SendBufferSize (inherited from Tcp) | Gets and sets the size of the system send buffer.
SendTimeout (inherited from Tcp) | Gets and sets the number of milliseconds that a Tcp.Send method will block before throwing a SocketException.
Site (inherited from Component) | Gets or sets the ISite of the Component.
Socket (inherited from Tcp) | Returns a reference to the System.Net.Sockets.Socket instance being used.
Stream (inherited from Tcp) | Returns a SegmentedStream that can be used for advanced streaming operations on the socket.
SynchronizingObject (inherited from Tcp) | Set this object to automatically control thread marshalling between worker threads and the main UI thread.
Tag (inherited from Tcp) | Gets or sets an object reference that can be used to associate this instance with any other.
TerminalTypeSpeed | Gets or sets terminal type and speed.

See Also

Rlogin Class | Dart.PowerTCP.Telnet Namespace


Rlogin.DisplayCharacters Property

Gets or sets character display information.

[Visual Basic]
Public Property DisplayCharacters As Size
[C#]
public System.Drawing.Size DisplayCharacters {get; set;}

Property Value

A System.Drawing.Size object representing the character display information.

Remarks

When using the Rlogin protocol, the remote host may request window size information. If the remote host requets this info, the Rlogin component will reply with the value of the Rlogin.DisplayCharacters property and the Rlogin.DisplayPixels property.

Rlogin.DisplayCharacters.Height represents the number of character rows. Defaults to 24. Rlogin.DisplayCharacters.Width represents the number of characters per row. Defaults to 72.

See Also

Rlogin Class | Dart.PowerTCP.Telnet Namespace


Rlogin.DisplayPixels Property

Gets or sets pixel display information.

[Visual Basic]
Public Property DisplayPixels As Size
[C#]
public System.Drawing.Size DisplayPixels {get; set;}

Property Value

A System.Drawing.Size object representing the pixel display information.

Remarks

When using the Rlogin protocol, the remote host may request window size information. If the remote host requets this info, the Rlogin component will reply with the value of the Rlogin.DisplayCharacters property and the Rlogin.DisplayPixels property.

Rlogin.DisplayPixels.Height represents the number of pixels for the client window in the Y direction. Defaults to 640. Rlogin.DisplayPixels.Width represents the number of pixels for the client window in the X direction. Defaults to 480.

See Also

Rlogin Class | Dart.PowerTCP.Telnet Namespace


Rlogin.Editor Property

In Visual Studio.NET, displays an interactive form to use to test real time protocol operations.

[Visual Basic]
Public Property Editor As Object
[C#]
public object Editor {get; set;}

Property Value

An EditorForm to use in VS.NET to test protocol operations.

Remarks

This property can only be used by clicking this property in the Properties Window in Visual Studio.NET. This will open an application which can be used to test protocol operation. The EditorForm will not be available if the PowerTCP component is being used as a reference.

The Object.Editor property can ONLY be used at design time in the Visual Studio.NET environment.

See Also

Rlogin Class | Dart.PowerTCP.Telnet Namespace


Rlogin.TerminalTypeSpeed Property

Gets or sets terminal type and speed.

[Visual Basic]
Public Property TerminalTypeSpeed As String
[C#]
public string TerminalTypeSpeed {get; set;}

Property Value

A string representing the terminal type and speed. Defaults to Defaults to "vt320/19200".

Remarks

As specified in the Rlogin protocol, client terminal type and terminal speed information is sent to the remote host during login. To do this using the Rlogin component, set this property before logging in using Rlogin.Login. The format for this string is [terminal type]/[terminal speed], for example "vt320/19200".

See Also

Rlogin Class | Dart.PowerTCP.Telnet Namespace


Rlogin Methods

The methods of the Rlogin class are listed below. For a complete list of Rlogin class members, see the Rlogin Members topic.

Public Instance Methods

BeginConnect | Overloaded. Asynchronously begin to connect to a remote host. Always throws a NotSupportedException.
BeginConnect (inherited from Tcp) | Overloaded. Connect to a server asynchronously, specifying the local interface and a range of local ports to use. The Tcp.EndConnect event is raised when completed.
BeginLogin | Overloaded. Asynchronously begin to login to a remote host.
BeginReceive (inherited from Tcp) | Overloaded. Receive data into your buffer asynchronously specifying a buffer, offset, size and SocketFlags value. The Tcp.EndReceive event is raised when completed.
BeginSend (inherited from Tcp) | Overloaded. Send data from your buffer asynchronously, specifying a buffer, offset, size and SocketFlags value. The Tcp.EndSend event is raised when completed.
Close (inherited from Tcp) | Overloaded. Close the connection.
Connect | Overloaded. Connect to a remote host. Always throws a NotSupportedException.
Connect (inherited from Tcp) | Overloaded. Connect to a host, specifying the local interface and a range of local ports to use.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from Component) | Releases all resources used by the Component.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Login | Overloaded. Login to a remote host.
Receive (inherited from Tcp) | Overloaded. Receive data from the host, specifying a buffer, offset, size and SocketFlags value.
Send (inherited from Tcp) | Overloaded. Send data to the server, specifying a buffer, offset, size and SocketFlags value.
ToString (inherited from Component) |
WaitFor | Reads data from the stream until the specified string is found.

See Also

Rlogin Class | Dart.PowerTCP.Telnet Namespace


BeginConnect Method

PowerTCP Telnet for .NET

Rlogin.BeginConnect Method

Asynchronously begin to connect to a remote host. Always throws a NotSupportedException.

Overload List

Inherited from Tcp.

public IAsyncResult BeginConnect(string,int);

Asynchronously begin to connect to a remote host. Always throws a NotSupportedException.

public override IAsyncResult BeginConnect(string,int,string,int,int,object);

Inherited from Tcp.

public IAsyncResult BeginConnect(string,int,string,int,object);

See Also

Rlogin Class | Dart.PowerTCP.Telnet Namespace


Rlogin.BeginConnect Method (String, Int32, String, Int32, Int32, Object)

Asynchronously begin to connect to a remote host. Always throws a NotSupportedException.

[Visual Basic]
Overrides Overloads Public Function BeginConnect( _
ByVal server As String, _
ByVal serverPort As Integer, _
ByVal client As String, _
ByVal clientPortMin As Integer, _
ByVal clientPortMax As Integer, _
ByVal state As Object _
) As IAsyncResult
[C#]
public override IAsyncResult BeginConnect(
string server,
int serverPort,
string client,
int clientPortMin,
int clientPortMax,
object state
);

Return Value

An IAsyncResult that represents the asynchronous operation, which could still be pending.

Remarks

Do not use this method with the Rlogin component. Use the Rlogin.BeginLogin method instead.

Exceptions

Exception Type | Condition
InvalidOperationException | Always thrown by this method.

See Also

Rlogin Class | Dart.PowerTCP.Telnet Namespace | Rlogin.BeginConnect Overload List


BeginLogin Method

PowerTCP Telnet for .NET

Rlogin.BeginLogin Method

Asynchronously begin to login to a remote host.

Overload List

Asynchronously begin to login to a remote host.

public IAsyncResult BeginLogin(string,string,object);

Asynchronously begin to login to a remote host.

public IAsyncResult BeginLogin(string,string,string,int,object);

Asynchronously begin to login to a remote host.

public IAsyncResult BeginLogin(string,string,string,object);

See Also

Rlogin Class | Dart.PowerTCP.Telnet Namespace


Rlogin.BeginLogin Method (String, String, Object)

Asynchronously begin to login to a remote host.

[Visual Basic]
Overloads Public Function BeginLogin( _
ByVal server As String, _
ByVal username As String, _
ByVal state As Object _
) As IAsyncResult
[C#]
public IAsyncResult BeginLogin(
string server,
string username,
object state
);

Parameters

server
Remote hostname or dot notation address.
username
Login name of the user.
state
User state information.

Return Value

An IAsyncResult that represents the asynchronous operation, which could still be pending.

Remarks

This method attempts to asynchronously login to the remote host server using the username username at the default port of 513. When the operation completes, The Rlogin.EndLogin event is raised, enabling you to write handling code. For example, you would want to check for an exception within this event, to be sure that login succeeded. Also, you would most likely want to begin receiving the initial data from the server.

If the username is configured for access from the client (by adding the information to the .rhosts file), then no interactive login prompt is provided by the server.

Since the rlogin and rsh protocols require a local port between 512 and 1023 (inclusive), this library starts at 1023 and attempts to bind to local ports working backwards. This feature allows you to use this protocol hundreds of times without running out of local ports.

Exceptions

Exception Type | Condition
InvalidOperationException | BeginXXX method used without providing an EndXXX event handler.

See Also

Rlogin Class | Dart.PowerTCP.Telnet Namespace | Rlogin.BeginLogin Overload List


Rlogin.BeginLogin Method (String, String, String, Int32, Object)

Asynchronously begin to login to a remote host.

[Visual Basic]
Overloads Public Function BeginLogin( _
ByVal server As String, _
ByVal username As String, _
ByVal clientUsername As String, _
ByVal serverPort As Integer, _
ByVal state As Object _
) As IAsyncResult
[C#]
public IAsyncResult BeginLogin(
string server,
string username,
string clientUsername,
int serverPort,
object state
);

Parameters

server
Remote hostname or dot notation address.
username
Login name of the user.
clientUsername
Login name of the user on the client host.
serverPort
Remote port to connect to.
state
User state information.

Return Value

An IAsyncResult that represents the asynchronous operation, which could still be pending.

Remarks

This method attempts to asynchronously login to the remote host server using the username username at the port remotePort. When the operation completes, The Rlogin.EndLogin event is raised, enabling you to write handling code. For example, you would want to check for an exception within this event, to be sure that login succeeded. Also, you would most likely want to begin receiving the initial data from the server.

If the username is configured for access from the client (by adding the information to the .rhosts file), then no interactive login prompt is provided by the server.

username is the login name of the user as known on the server. clientUsername may be used to provide additional information that the Login name of the user on the client is different.

Since the rlogin and rsh protocols require a local port between 512 and 1023 (inclusive), this library starts at 1023 and attempts to bind to local ports working backwards. This feature allows you to use this protocol hundreds of times without running out of local ports.

Exceptions

Exception Type | Condition
InvalidOperationException | BeginXXX method used without providing an EndXXX event handler.

See Also

Rlogin Class | Dart.PowerTCP.Telnet Namespace | Rlogin.BeginLogin Overload List


Rlogin.BeginLogin Method (String, String, String, Object)

Asynchronously begin to login to a remote host.

[Visual Basic]
Overloads Public Function BeginLogin( _
ByVal server As String, _
ByVal username As String, _
ByVal clientUsername As String, _
ByVal state As Object _
) As IAsyncResult
[C#]
public IAsyncResult BeginLogin(
string server,
string username,
string clientUsername,
object state
);

Parameters

server
Remote hostname or dot notation address.
username
Login name of the user.
clientUsername
Login name of the user on the client host.
state
User state information.

Return Value

An IAsyncResult that represents the asynchronous operation, which could still be pending.

Remarks

This method attempts to asynchronously login to the remote host server using the username username at the default port of 513. When the operation completes, The Rlogin.EndLogin event is raised, enabling you to write handling code. For example, you would want to check for an exception within this event, to be sure that login succeeded. Also, you would most likely want to begin receiving the initial data from the server.

If the username is configured for access from the client (by adding the information to the .rhosts file), then no interactive login prompt is provided by the server.

username is the login name of the user as known on the server. clientUsername may be used to provide additional information that the Login name of the user on the client is different.

Since the rlogin and rsh protocols require a local port between 512 and 1023 (inclusive), this library starts at 1023 and attempts to bind to local ports working backwards. This feature allows you to use this protocol hundreds of times without running out of local ports.

Exceptions

Exception Type | Condition
InvalidOperationException | BeginXXX method used without providing an EndXXX event handler.

See Also

Rlogin Class | Dart.PowerTCP.Telnet Namespace | Rlogin.BeginLogin Overload List


Connect Method

PowerTCP Telnet for .NET

Rlogin.Connect Method

Connect to a remote host. Always throws a NotSupportedException.

Overload List

Inherited from Tcp.

public void Connect(string,int);

Inherited from Tcp.

public void Connect(string,int,string,int);

Connect to a remote host. Always throws a NotSupportedException.

public override void Connect(string,int,string,int,int);

Inherited from Tcp.

public void Connect(string,string);

See Also

Rlogin Class | Dart.PowerTCP.Telnet Namespace


Rlogin.Connect Method (String, Int32, String, Int32, Int32)

Connect to a remote host. Always throws a NotSupportedException.

[Visual Basic]
Overrides Overloads Public Sub Connect( _
ByVal server As String, _
ByVal serverPort As Integer, _
ByVal client As String, _
ByVal clientPortMin As Integer, _
ByVal clientPortMax As Integer _
)
[C#]
public override void Connect(
string server,
int serverPort,
string client,
int clientPortMin,
int clientPortMax
);

Remarks

Do not use this method with the Rlogin component. Use the Rlogin.Login method instead.

Exceptions

Exception Type | Condition
InvalidOperationException | Always thrown by this method.

See Also

Rlogin Class | Dart.PowerTCP.Telnet Namespace | Rlogin.Connect Overload List


Login Method

PowerTCP Telnet for .NET

Rlogin.Login Method

Login to a remote host.

Overload List

Login to a remote host.

public void Login(string);

Login to a remote host.

public void Login(string,string);

Login to a remote host.

public void Login(string,string,string);

Login to a remote host using a non-standard port.

public void Login(string,string,string,int);

See Also

Rlogin Class | Dart.PowerTCP.Telnet Namespace


Rlogin.Login Method (String)

Login to a remote host.

[Visual Basic]
Overloads Public Sub Login( _
ByVal server As String _
)
[C#]
public void Login(
string server
);

Parameters

server
Remote hostname or dot notation address.

Remarks

This method attempts to login to the remote host server at the default port of 513. When this method returns, typically you would receive data from the server using Rlogin.Receive or Rlogin.BeginReceive. Send data to the server using Rlogin.Send or Rlogin.BeginSend.

If this method is used to login to a server, the server will always provide prompts for an interactive login because no user information was sent to the server.

Since the rlogin and rsh protocols require a local port between 512 and 1023 (inclusive), this library starts at 1023 and attempts to bind to local ports working backwards. This feature allows you to use this protocol hundreds of times without running out of local ports.

Exceptions

Exception Type | Condition
SocketException | The remote host cannot be found.

See Also

Rlogin Class | Dart.PowerTCP.Telnet Namespace | Rlogin.Login Overload List


Rlogin.Login Method (String, String)

Login to a remote host.

[Visual Basic]
Overloads Public Sub Login( _
ByVal server As String, _
ByVal username As String _
)
[C#]
public void Login(
string server,
string username
);

Parameters

server
Remote hostname or dot notation address.
username
Login name of the user.

Remarks

This method attempts to login to the remote host server using the username username at the default port of 513. When this method returns, typically you would receive data from the server using Rlogin.Receive or Rlogin.BeginReceive. Send data to the server using Rlogin.Send or Rlogin.BeginSend.

If the username is configured for access from the client (by adding the information to the .rhosts file), then no interactive login prompt is provided by the server.

Since the rlogin and rsh protocols require a local port between 512 and 1023 (inclusive), this library starts at 1023 and attempts to bind to local ports working backwards. This feature allows you to use this protocol hundreds of times without running out of local ports.

Exceptions

Exception Type | Condition
SocketException | The remote host cannot be found.

See Also

Rlogin Class | Dart.PowerTCP.Telnet Namespace | Rlogin.Login Overload List


Rlogin.Login Method (String, String, String)

Login to a remote host.

[Visual Basic]
Overloads Public Sub Login( _
ByVal server As String, _
ByVal username As String, _
ByVal clientUsername As String _
)
[C#]
public void Login(
string server,
string username,
string clientUsername
);

Parameters

server
Remote hostname or dot notation address.
username
Login name of the user.
clientUsername
Login name of the user on the client host.

Remarks

This method attempts to login to the remote host server using the username username at the default port of 513. When this method returns, typically you would receive data from the server using Rlogin.Receive or Rlogin.BeginReceive. Send data to the server using Rlogin.Send or Rlogin.BeginSend.

If the username is configured for access from the client (by adding the information to the .rhosts file), then no interactive login prompt is provided by the server.

username is the login name of the user as known on the server. clientUsername may be used to provide additional information that the Login name of the user on the client is different.

Since the rlogin and rsh protocols require a local port between 512 and 1023 (inclusive), this library starts at 1023 and attempts to bind to local ports working backwards. This feature allows you to use this protocol hundreds of times without running out of local ports.

Exceptions

Exception Type | Condition
SocketException | The remote host cannot be found.

See Also

Rlogin Class | Dart.PowerTCP.Telnet Namespace | Rlogin.Login Overload List


Rlogin.Login Method (String, String, String, Int32)

Login to a remote host using a non-standard port.

[Visual Basic]
Overloads Public Sub Login( _
ByVal server As String, _
ByVal username As String, _
ByVal clientUsername As String, _
ByVal serverPort As Integer _
)
[C#]
public void Login(
string server,
string username,
string clientUsername,
int serverPort
);

Parameters

server
Remote hostname or dot notation address.
username
Login name of the user.
clientUsername
Login name of the user on the client host.
serverPort
The remote port to connect to.

Remarks

This method attempts to login to the remote host server using the username username and the port. When this method returns, typically you would receive data from the server using Rlogin.Receive or Rlogin.BeginReceive. Send data to the server using Rlogin.Send or Rlogin.BeginSend.

If the username is configured for access from the client (by adding the information to the .rhosts file), then no interactive login prompt is provided by the server.

username is the login name of the user as known on the server. clientUsername may be used to provide additional information that the Login name of the user on the client is different.

Since the rlogin and rsh protocols require a local port between 512 and 1023 (inclusive), this library starts at 1023 and attempts to bind to local ports working backwards. This feature allows you to use this protocol hundreds of times without running out of local ports.

Exceptions

Exception Type | Condition
SocketException | The remote host cannot be found.

See Also

Rlogin Class | Dart.PowerTCP.Telnet Namespace | Rlogin.Login Overload List


Rlogin.WaitFor Method

Reads data from the stream until the specified string is found.

[Visual Basic]
Public Function WaitFor( _
ByVal prompt As String _
) As String
[C#]
public string WaitFor(
string prompt
);

Parameters

prompt
Data is read until this string is found.

Return Value

A string containing all data read from the stream.

Remarks

This method reads from the data stream until the specified string is found or the method times out. Often, it is useful when communicating with a server to be able to read data until a token is found. For example, during the login operation the server may send a string "login:". You could use the Rlogin.WaitFor method to keep reading until you find "login:", then issue your login command.

This method will block for the amount of time specified in Rlogin.ReceiveTimeout. If Rlogin.ReceiveTimeout is 0, this method will throw an exception. If prompt is not found within the time specified by Telnet.ReceiveTimeout, a System.SocketException is thrown (with the timeout ErrorCode of 10060).

Exceptions

Exception Type | Condition
SocketException | prompt was not found within the specified period of time.
InvalidOperationException | Telnet.ReceiveTimeout is 0.

See Also

Rlogin Class | Dart.PowerTCP.Telnet Namespace


Rlogin Events

The events of the Rlogin class are listed below. For a complete list of Rlogin class members, see the Rlogin Members topic.

Public Instance Events

ConnectedChanged (inherited from Tcp) | Raised when the value of the Object.Connected property changes.
Disposed (inherited from Component) | Adds an event handler to listen to the Disposed event on the component.
EndConnect (inherited from Tcp) | Raised when the Tcp.BeginConnect request completes.
EndLogin | Raised when the Rlogin.BeginLogin request completes.
EndReceive (inherited from Tcp) | Raised when the Tcp.BeginReceive request completes.
EndSend (inherited from Tcp) | Raised when the Tcp.BeginSend request completes.
RawTrace (inherited from Tcp) | Raised when data has been sent/received.
Trace (inherited from Tcp) | Raised when data has been sent/received.

See Also

Rlogin Class | Dart.PowerTCP.Telnet Namespace


Rlogin.EndLogin Event

Raised when the Rlogin.BeginLogin request completes.

[Visual Basic]
Public Event EndLogin As ConnectEventHandler
[C#]
public event ConnectEventHandler EndLogin;

Event Data

The event handler receives an argument of type ExceptionEventArgs containing data related to this event. The following ExceptionEventArgs properties provide information specific to this event.

Property | Description
Exception | Gets any exception which occurred during the asynchronous operation.
State | Gets the object that was included as part of the associated method call.

Remarks

This event is raised when the asynchronous Rlogin.BeginLogin operation completes. An EventArgs object is passed into the event, containing information about the event.

For more information on using events using PowerTCP.NET within the Visual Studio.NET environment, see the topic, "Using Events Within The Visual Studio.NET Environment".

If you are using the Rlogin component as a reference, you must create a method to handle the event yourself.

This event MUST be implemented if you are using the Rlogin.BeginLogin method. See the topic "Using EndXXX Events" for more information.

See Also

Rlogin Class | Dart.PowerTCP.Telnet Namespace


Rsh Class

The Rsh component enables use of the remote shell protocol within any .NET application.

For a list of all members of this type, see Rsh Members.

System.Object
MarshalByRefObject
Component
Rsh

[Visual Basic]
Public Class Rsh
Inherits Component
[C#]
public class Rsh : Component

Remarks

Use the Rsh component to execute shell commands on a remote host (typically a UNIX host). To use the Rsh component, call Rsh.Execute, passing in the appropriate parameters. A Segment object is returned, encapsulating the response from the server. Behind-the-scenes the Rsh component will connect to the remote host, login, send the command, receive the response, and logout.

Rexec and Rsh do the same thing using different authentication techniques. Whereas Rsh requires static information be added to .rhosts and/or equiv , Rexec simply uses dynamic username/password information for authentication.

Using Rsh requires authorization for the local host running your application. This is done by adding the proper entries to the hosts.equiv or .rhosts files located on the remote host. These files enable logins to be performed from other machines and users. The hosts.equiv file is a system file containing names of remote hosts authorized to execute the remote protocol. If not authorized in this file, the remote host looks for the .rhosts file located in the user's account on the remote host. The .rhosts file contains lines of host names and login names paired together. Your local host with login name is authorized if found in this file.

Example

[Visual Basic, C#] The following example demonstrates simple use of the Rsh component.

[Visual Basic]
' Execute a command
Dim Seg As Segment = Rsh1.Execute("myserver", "myuser", "pwd")

' Display the result
Debug.WriteLine("Current directory: " + Seg.ToString())
[C#]
// Execute a command
Segment seg = Rsh1.Execute("myserver", "myuser", "pwd");

// Display the result
Debug.WriteLine("Current directory: " + seg.ToString());

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

Rsh Members | Dart.PowerTCP.Telnet Namespace


Rsh Members

Rsh overview

Public Instance Constructors

Rsh Overloaded. Initializes a new instance of the Rsh class.

Public Instance Properties

Connection |
Container (inherited from Component) | Gets the IContainer that contains the Component.
DoEvents | Gets or sets a value that controls the processing of events during blocking method calls.
Editor | In Visual Studio.NET, displays an interactive form to use to test real time protocol operations.
Site (inherited from Component) | Gets or sets the ISite of the Component.
SynchronizingObject |

Public Instance Methods

BeginExecute | Overloaded. Begin to asynchronously execute a command on a remote host.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from Component) | Releases all resources used by the Component.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Execute | Overloaded. Execute a command on a remote host.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
ToString (inherited from Component) |

Public Instance Events

Disposed (inherited from Component) | Adds an event handler to listen to the Disposed event on the component.
EndExecute | Raised when the Rsh.BeginExecute request completes.

See Also

Rsh Class | Dart.PowerTCP.Telnet Namespace


Rsh Constructor

Create a new instance of the Rsh component.

Overload List

Create a new instance of the Rsh component.

public Rsh();

Create a new instance of the Rsh component.

public Rsh(IContainer);

See Also

Rsh Class | Dart.PowerTCP.Telnet Namespace


Rsh Constructor (IContainer)

Create a new instance of the Rsh component.

[Visual Basic]
Overloads Public Sub New( _
ByVal container As IContainer _
)
[C#]
public Rsh(
IContainer container
);

Remarks

This constructor initializes a new instance of the Rsh component, adding it to the specified IContainer container.

To create an instance of the Rsh component using Visual Studio.NET, simply add the Rsh component to the form and the object will automatically be created and initialized. If working out of the Visual Studio.NET environment (or using the Rsh component as a reference), the Rsh component will have to be explicitly created and initialized.

The following table shows initial property values for an instance of Rsh.

Property | Initial Value
Rsh.Connection | Tcp object
Rsh.DoEvents | True

See Also

Rsh Class | Dart.PowerTCP.Telnet Namespace | Rsh Constructor Overload List


Rsh Constructor ()

Create a new instance of the Rsh component.

[Visual Basic]
Overloads Public Sub New()
[C#]
public Rsh();

Remarks

The default constructor initializes a new instance of Rsh.

To create an instance of the Rsh component using Visual Studio.NET, simply add the Rsh component to the form and the object will automatically be created and initialized. If working out of the Visual Studio.NET environment (or using the Rsh component as a reference), the Rsh component will have to be explicitly created and initialized.

The following table shows initial property values for an instance of Rsh.

Property | Initial Value
Rsh.Connection | Tcp object
Rsh.DoEvents | True

See Also

Rsh Class | Dart.PowerTCP.Telnet Namespace | Rsh Constructor Overload List


Rsh Properties

The properties of the Rsh class are listed below. For a complete list of Rsh class members, see the Rsh Members topic.

Public Instance Properties

Connection |
Container (inherited from Component) | Gets the IContainer that contains the Component.
DoEvents | Gets or sets a value that controls the processing of events during blocking method calls.
Editor | In Visual Studio.NET, displays an interactive form to use to test real time protocol operations.
Site (inherited from Component) | Gets or sets the ISite of the Component.
SynchronizingObject |

See Also

Rsh Class | Dart.PowerTCP.Telnet Namespace


Rsh.Connection Property

[Visual Basic]
Public ReadOnly Property Connection As Tcp
[C#]
public Tcp Connection {get;}

See Also

Rsh Class | Dart.PowerTCP.Telnet Namespace


Rsh.DoEvents Property

Gets or sets a value that controls the processing of events during blocking method calls.

[Visual Basic]
Public Property DoEvents As Boolean
[C#]
public bool DoEvents {get; set;}

Property Value

true if user-interface events should be processed during synchronous method calls; otherwise, false. The default value is true.

Remarks

When performing a synchronous (blocking) method, PowerTCP will process user-interface events (such as window painting) if this property is set to true AND the current thread has an event message queue. If no message queue is present (such as on an ASP page or under any worker thread), the value of this property has no effect. This property is used only for synchronous methods. Object.DoEvents is not needed if using asynchronous methods because the asynchronous method will execute on a different thread, allowing the UI thread to continue working unblocked.

For example, this property is beneficial when an interactive application is being used and the user may want to abort a currently processing operation by clicking an "Abort" button. If Object.DoEvents is set to false, this will not be possible. Set the Object.DoEvents property to true and the application will respond to other events (such as button clicks) during synchronous operations.

See Also

Rsh Class | Dart.PowerTCP.Telnet Namespace


Rsh.Editor Property

In Visual Studio.NET, displays an interactive form to use to test real time protocol operations.

[Visual Basic]
Public Property Editor As Object
[C#]
public object Editor {get; set;}

Property Value

An EditorForm to use in VS.NET to test protocol operations.

Remarks

This property can only be used by clicking this property in the Properties Window in Visual Studio.NET. This will open an application which can be used to test protocol operation. The EditorForm will not be available if the PowerTCP component is being used as a reference.

The Object.Editor property can ONLY be used at design time in the Visual Studio.NET environment.

See Also

Rsh Class | Dart.PowerTCP.Telnet Namespace


Rsh Methods

The methods of the Rsh class are listed below. For a complete list of Rsh class members, see the Rsh Members topic.

Public Instance Methods

BeginExecute | Overloaded. Begin to asynchronously execute a command on a remote host.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from Component) | Releases all resources used by the Component.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Execute | Overloaded. Execute a command on a remote host.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
ToString (inherited from Component) |

See Also

Rsh Class | Dart.PowerTCP.Telnet Namespace


BeginExecute Method

PowerTCP Telnet for .NET

Rsh.BeginExecute Method

Begin to asynchronously execute a command on a remote host.

Overload List

Begin to asynchronously execute a command on a remote host.

public IAsyncResult BeginExecute(string,string,string,object);

Begin to asynchronously execute a command on a remote host, specifying the remote port to use.

public IAsyncResult BeginExecute(string,string,string,string,int,object);

Begin to asynchronously execute a command on a remote host.

public IAsyncResult BeginExecute(string,string,string,string,object);

See Also

Rsh Class | Dart.PowerTCP.Telnet Namespace


Rsh.BeginExecute Method (String, String, String, Object)

Begin to asynchronously execute a command on a remote host.

[Visual Basic]
Overloads Public Function BeginExecute( _
ByVal server As String, _
ByVal username As String, _
ByVal command As String, _
ByVal state As Object _
) As IAsyncResult
[C#]
public IAsyncResult BeginExecute(
string server,
string username,
string command,
object state
);

Parameters

server
The remote host to execute the command on.
username
The login name of the user account.
command
The command to execute.
state
User state information.

Return Value

An IAsyncResult that represents the asynchronous operation, which could still be pending.

Remarks

This method attempts to connect to the remote host specified by server, executes the command specified by command, then disconnects. Upon completion, the Rsh.EndExecute is raised. A SegmentEventArgs object is passed into the Rsh.EndExecute event and encapsulates the response from the server.

Since the rlogin and rsh protocols require a local port between 512 and 1023 (inclusive), this library starts at 1023 and attempts to bind to local ports working backwards. This feature allows you to use this protocol hundreds of times without running out of local ports.

Exceptions

Exception Type | Condition
InvalidOperationException | BeginXXX method used without providing an EndXXX event handler.

Example

[Visual Basic, C#] The following example demonstrates simple use of the Rsh component to asynchronously execute a command.

[Visual Basic]
   ' Execute a command. When completed the Rsh.EndExecute event will be raised.
   Rsh1.BeginExecute("myserver", "myuser", "pwd", Nothing)

Private Sub Rsh1_EndExecute(ByVal sender As Object, ByVal e As Dart.PowerTCP.Telnet.SegmentEventArgs) Handles Rsh1.EndExecute
    Debug.WriteLine("Current directory: " + e.Segment.ToString())
End Sub
[C#]
   ' Execute a command. When completed the Rsh.EndExecute event will be raised.
   rsh1.BeginExecute("myserver", "myuser", "pwd", null);

private void rsh1_EndExecute(object sender, Dart.PowerTCP.Telnet.SegmentEventArgs e)
{
   Debug.WriteLine("Current directory: " + e.Segment.ToString());
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Rsh Class | Dart.PowerTCP.Telnet Namespace | Rsh.BeginExecute Overload List


Rsh.BeginExecute Method (String, String, String, String, Int32, Object)

Begin to asynchronously execute a command on a remote host, specifying the remote port to use.

[Visual Basic]
Overloads Public Function BeginExecute( _
ByVal server As String, _
ByVal username As String, _
ByVal command As String, _
ByVal clientUsername As String, _
ByVal serverPort As Integer, _
ByVal state As Object _
) As IAsyncResult
[C#]
public IAsyncResult BeginExecute(
string server,
string username,
string command,
string clientUsername,
int serverPort,
object state
);

Parameters

server
The remote host to execute the command on.
username
The login name of the user account.
command
The command to execute.
clientUsername
Login name of the user on the client host.
serverPort
The remote port to connect to.
state
User state information.

Return Value

An IAsyncResult that represents the asynchronous operation, which could still be pending.

Remarks

This method attempts to connect to the remote host specified by server and serverPort, executes the command specified by command, then disconnects. Upon completion, the Rsh.EndExecute is raised. A SegmentEventArgs object is passed into the Rsh.EndExecute event and encapsulates the response from the server.

username is the login name of the user as known on the server. clientUsername may be used to provide additional information that the Login name of the user on the client is different.

Since the rlogin and rsh protocols require a local port between 512 and 1023 (inclusive), this library starts at 1023 and attempts to bind to local ports working backwards. This feature allows you to use this protocol hundreds of times without running out of local ports.

Exceptions

Exception Type | Condition
InvalidOperationException | BeginXXX method used without providing an EndXXX event handler.

Example

[Visual Basic, C#] The following example demonstrates simple use of the Rsh component to asynchronously execute a command.

[Visual Basic]
   ' Execute a command. When completed the Rsh.EndExecute event will be raised.
   Rsh1.BeginExecute("myserver", "myuser", "pwd", "myclientuser", 5000, Nothing)

Private Sub Rsh1_EndExecute(ByVal sender As Object, ByVal e As Dart.PowerTCP.Telnet.SegmentEventArgs) Handles Rsh1.EndExecute
    Debug.WriteLine("Current directory: " + e.Segment.ToString())
End Sub
[C#]
   ' Execute a command. When completed the Rsh.EndExecute event will be raised.
   rsh1.BeginExecute("myserver", "myuser", "pwd", "myclientuser", 5000, null);

private void rsh1_EndExecute(object sender, Dart.PowerTCP.Telnet.SegmentEventArgs e)
{
   Debug.WriteLine("Current directory: " + e.Segment.ToString());
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Rsh Class | Dart.PowerTCP.Telnet Namespace | Rsh.BeginExecute Overload List


Rsh.BeginExecute Method (String, String, String, String, Object)

Begin to asynchronously execute a command on a remote host.

[Visual Basic]
Overloads Public Function BeginExecute( _
ByVal server As String, _
ByVal username As String, _
ByVal command As String, _
ByVal clientUsername As String, _
ByVal state As Object _
) As IAsyncResult
[C#]
public IAsyncResult BeginExecute(
string server,
string username,
string command,
string clientUsername,
object state
);

Parameters

server
The remote host to execute the command on.
username
The login name of the user account.
command
The command to execute.
clientUsername
Login name of the user on the client host.
state
User state information.

Return Value

An IAsyncResult that represents the asynchronous operation, which could still be pending.

Remarks

This method attempts to connect to the remote host specified by server, executes the command specified by command, then disconnects. Upon completion, the Rsh.EndExecute is raised. A SegmentEventArgs object is passed into the Rsh.EndExecute event and encapsulates the response from the server.

username is the login name of the user as known on the server. clientUsername may be used to provide additional information that the Login name of the user on the client is different.

Since the rlogin and rsh protocols require a local port between 512 and 1023 (inclusive), this library starts at 1023 and attempts to bind to local ports working backwards. This feature allows you to use this protocol hundreds of times without running out of local ports.

Exceptions

Exception Type | Condition
InvalidOperationException | BeginXXX method used without providing an EndXXX event handler.

Example

[Visual Basic, C#] The following example demonstrates simple use of the Rsh component to asynchronously execute a command.

[Visual Basic]
   ' Execute a command. When completed the Rsh.EndExecute event will be raised.
   Rsh1.BeginExecute("myserver", "myuser", "pwd", "myclientuser", Nothing)

Private Sub Rsh1_EndExecute(ByVal sender As Object, ByVal e As Dart.PowerTCP.Telnet.SegmentEventArgs) Handles Rsh1.EndExecute
    Debug.WriteLine("Current directory: " + e.Segment.ToString())
End Sub
[C#]
   ' Execute a command. When completed the Rsh.EndExecute event will be raised.
   rsh1.BeginExecute("myserver", "myuser", "pwd", "myclientuser", null);

private void rsh1_EndExecute(object sender, Dart.PowerTCP.Telnet.SegmentEventArgs e)
{
   Debug.WriteLine("Current directory: " + e.Segment.ToString());
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Rsh Class | Dart.PowerTCP.Telnet Namespace | Rsh.BeginExecute Overload List


Execute Method

PowerTCP Telnet for .NET

Rsh.Execute Method

Execute a command on a remote host.

Overload List

Execute a command on a remote host.

public Segment Execute(string,string,string);

Execute a command on a remote host.

public Segment Execute(string,string,string,string);

Execute a command on a remote host, specifying the remote port to connect to.

public Segment Execute(string,string,string,string,int);

See Also

Rsh Class | Dart.PowerTCP.Telnet Namespace


Rsh.Execute Method (String, String, String)

Execute a command on a remote host.

[Visual Basic]
Overloads Public Function Execute( _
ByVal server As String, _
ByVal username As String, _
ByVal command As String _
) As Segment
[C#]
public Segment Execute(
string server,
string username,
string command
);

Parameters

server
The remote host to execute the command on.
username
The login name of the user account.
command
The command to execute.

Return Value

A Segment object encapsulating the response from the server.

Remarks

This method attempts to connect to the remote host specified by server, executes the command specified by command, then disconnects. A Segment object is returned from this object, encapsulating the response from the server.

Since the rlogin and rsh protocols require a local port between 512 and 1023 (inclusive), this library starts at 1023 and attempts to bind to local ports working backwards. This feature allows you to use this protocol hundreds of times without running out of local ports.

Exceptions

Exception Type | Condition
SocketException | The remote host does not exist or is unreachable.

Example

[Visual Basic, C#] The following example demonstrates simple use of the Rsh component.

[Visual Basic]
' Execute a command
Dim Seg As Segment = Rsh1.Execute("myserver", "myuser", "pwd")

' Display the result
Debug.WriteLine("Current directory: " + Seg.ToString())
[C#]
// Execute a command
Segment seg = Rsh1.Execute("myserver", "myuser", "pwd");

// Display the result
Debug.WriteLine("Current directory: " + seg.ToString());

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Rsh Class | Dart.PowerTCP.Telnet Namespace | Rsh.Execute Overload List


Rsh.Execute Method (String, String, String, String)

Execute a command on a remote host.

[Visual Basic]
Overloads Public Function Execute( _
ByVal server As String, _
ByVal username As String, _
ByVal command As String, _
ByVal clientUsername As String _
) As Segment
[C#]
public Segment Execute(
string server,
string username,
string command,
string clientUsername
);

Parameters

server
The remote host to execute the command on.
username
The login name of the user account.
command
The command to execute.
clientUsername
Login name of the user on the client host.

Return Value

A Segment object encapsulating the response from the server.

Remarks

This method attempts to connect to the remote host specified by server, executes the command specified by command, then disconnects. A Segment object is returned from this object, encapsulating the response from the server.

username is the login name of the user as known on the server. clientUsername may be used to provide additional information that the Login name of the user on the client is different.

Since the rlogin and rsh protocols require a local port between 512 and 1023 (inclusive), this library starts at 1023 and attempts to bind to local ports working backwards. This feature allows you to use this protocol hundreds of times without running out of local ports.

Exceptions

Exception Type | Condition
SocketException | The remote host does not exist or is unreachable.
ProtocolException | Bad response received from server.

Example

[Visual Basic, C#] The following example demonstrates simple use of the Rsh component.

[Visual Basic]
' Execute a command
Dim Seg As Segment = Rsh1.Execute("myserver", "myuser", "pwd", "myclientuser")

' Display the result
Debug.WriteLine("Current directory: " + Seg.ToString())
[C#]
// Execute a command
Segment seg = rsh1.Execute("myserver", "myuser", "pwd", "myclientuser");

// Display the result
Debug.WriteLine("Current directory: " + seg.ToString());

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Rsh Class | Dart.PowerTCP.Telnet Namespace | Rsh.Execute Overload List


Rsh.Execute Method (String, String, String, String, Int32)

Execute a command on a remote host, specifying the remote port to connect to.

[Visual Basic]
Overloads Public Function Execute( _
ByVal server As String, _
ByVal username As String, _
ByVal command As String, _
ByVal clientUsername As String, _
ByVal serverPort As Integer _
) As Segment
[C#]
public Segment Execute(
string server,
string username,
string command,
string clientUsername,
int serverPort
);

Parameters

server
The remote host to execute the command on.
username
The login name of the user account.
command
The command to execute.
clientUsername
Login name of the user on the client host.
serverPort
The remote port to connect to.

Return Value

A Segment object encapsulating the response from the server.

Remarks

This method attempts to connect to the remote host specified by server and serverPort, executes the command specified by command, then disconnects. A Segment object is returned from this object, encapsulating the response from the server.

username is the login name of the user as known on the server. clientUsername may be used to provide additional information that the Login name of the user on the client is different.

Since the rlogin and rsh protocols require a local port between 512 and 1023 (inclusive), this library starts at 1023 and attempts to bind to local ports working backwards. This feature allows you to use this protocol hundreds of times without running out of local ports.

Exceptions

Exception Type | Condition
SocketException | The remote host does not exist or is unreachable.
ProtocolException | Bad response received from server.

Example

[Visual Basic, C#] The following example demonstrates simple use of the Rsh component using a non-standard port.

[Visual Basic]
' Execute a command, using a non-standard port
Dim Seg As Segment = Rsh1.Execute("myserver", "myuser", "pwd", "myclientuser", 5000)

' Display the result
Debug.WriteLine("Current directory: " + Seg.ToString())
[C#]
// Execute a command, using a non-standard port
Segment seg = rsh1.Execute("myserver", "myuser", "pwd", "myclientuser", 5000);

// Display the result
Debug.WriteLine("Current directory: " + seg.ToString());

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Rsh Class | Dart.PowerTCP.Telnet Namespace | Rsh.Execute Overload List


Rsh Events

The events of the Rsh class are listed below. For a complete list of Rsh class members, see the Rsh Members topic.

Public Instance Events

Disposed (inherited from Component) | Adds an event handler to listen to the Disposed event on the component.
EndExecute | Raised when the Rsh.BeginExecute request completes.

See Also

Rsh Class | Dart.PowerTCP.Telnet Namespace


Rsh.EndExecute Event

Raised when the Rsh.BeginExecute request completes.

[Visual Basic]
Public Event EndExecute As SegmentEventHandler
[C#]
public event SegmentEventHandler EndExecute;

Event Data

The event handler receives an argument of type SegmentEventArgs containing data related to this event. The following SegmentEventArgs properties provide information specific to this event.

Property | Description
Exception | Gets any exception which occurred during the asynchronous operation.
Segment | The Segment object referencing the data that was sent or received.
State | Gets the object that was included as part of the associated method call.

Remarks

This event is raised when the asynchronous operation started by Rsh.BeginExecute completes. A SegmentEventArgs object is passed into the event, containing information about the event, such as the response from the remote host.

If any errors occurred during the asynchronous operation, they would be returned in the SegmentEventArgs object, check SegmentEventArgs.Exception to check for any exception.

For more information on using events using PowerTCP.NET within the Visual Studio.NET environment, see the topic, "Using Events Within The Visual Studio.NET Environment".

If you are using the Rexec component as a reference, you must create a method to handle the event yourself.

This event MUST be implemented if you are using the Rsh.BeginExecute method. See the topic "Using EndXXX Events" for more information.

Example

[Visual Basic, C#] The following example demonstrates simple use of the Rsh component to asynchronously execute a command.

[Visual Basic]
   ' Execute a command. When completed the Rsh.EndExecute event will be raised.
   Rsh1.BeginExecute("myserver", "myuser", "pwd", Nothing)

Private Sub Rsh1_EndExecute(ByVal sender As Object, ByVal e As Dart.PowerTCP.Telnet.SegmentEventArgs) Handles Rsh1.EndExecute
    Debug.WriteLine("Current directory: " + e.Segment.ToString())
End Sub
[C#]
   ' Execute a command. When completed the Rsh.EndExecute event will be raised.
   rsh1.BeginExecute("myserver", "myuser", "pwd", null);

private void rsh1_EndExecute(object sender, Dart.PowerTCP.Telnet.SegmentEventArgs e)
{
   Debug.WriteLine("Current directory: " + e.Segment.ToString());
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Rsh Class | Dart.PowerTCP.Telnet Namespace


Segment Class

Provides a reference to a data segment where data is sent or received over a TCP stream.

For a list of all members of this type, see Segment Members.

System.Object
Segment

[Visual Basic]
Public Class Segment
[C#]
public class Segment

Remarks

When data is sent or received when using the Tcp component (which may be by using the Tcp component directly, or by using another component that uses the Tcp compoent for the underlying connection), a Segment object is returned. This Segment oject will contain data such as the data sent or received and the amount of bytes sent or received. To use the data, simply access the Segment.Buffer property using the offset specified by the Segment.Offset property. As a shortcut, the Segment.ToString method can be used to simply return all data sent or received as a string.

The Segment object is also used by other components beside the Tcp component. For example, several components have a Trace event which allows access to any data sent or received over the control connection. A SegmentEventArgs class is made accessable in this event, containing a Segment object describing the data sent or received.

Example

[Visual Basic, C#] The following example demonstrates connecting to a server while specifying a local interface to use.

[Visual Basic]
' Connect to the server, specifying the local interface to use
Tcp1.Connect("atropos", 13, "192.168.0.83", 8888)

' Since connection was to DAYTIME port (13), simply receive the time
Dim seg As Segment = Tcp1.Receive()

Debug.WriteLine("Time reported by server: " + seg.ToString())
[C#]
// Connect to the server, specifying the local interface to use
tcp1.Connect("atropos", 13, "192.168.0.83", 8888);

// Since connection was to DAYTIME port (13), simply receive the time
Segment seg = tcp1.Receive();

Debug.WriteLine("Time reported by server: " + seg.ToString());

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

Segment Members | Dart.PowerTCP.Telnet Namespace


Segment Members

Segment overview

Public Instance Properties

Buffer | The buffer containing the data that was sent/received.
Count | The amount of bytes that were sent/received.
Offset | The offset into the buffer.
Sent | Indicates whether the data was sent or received.
SocketFlags | Gets the SocketFlags associated with the Segment.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString | Returns all data sent/received as a string.

See Also

Segment Class | Dart.PowerTCP.Telnet Namespace


Segment Properties

The properties of the Segment class are listed below. For a complete list of Segment class members, see the Segment Members topic.

Public Instance Properties

Buffer | The buffer containing the data that was sent/received.
Count | The amount of bytes that were sent/received.
Offset | The offset into the buffer.
Sent | Indicates whether the data was sent or received.
SocketFlags | Gets the SocketFlags associated with the Segment.

See Also

Segment Class | Dart.PowerTCP.Telnet Namespace


Segment.Buffer Property

The buffer containing the data that was sent/received.

[Visual Basic]
Public ReadOnly Property Buffer As Byte()
[C#]
public byte[] Buffer {get;}

Property Value

A byte array containing data that was sent/received over the socket.

Remarks

When using the Tcp component, using Tcp.Send or Tcp.Receive will return a Segment object. The data sent/received is available through Segment.Buffer.

When using the Udp component, using Udp.Send or Udp.Receive will return a Datagram object. The data sent/received is available through Datagram.Buffer.

When using other PowerTCP components, a Segment or Datagram object (which one depends on if TCP or UDP is used as the transport protocol) is made available to describe data sent or received, often in a Trace event. The Segment.Buffer or Datagram.Buffer property contains the actual data sent or received.

Example

[Visual Basic, C#] The following example demonstrates connecting to a server while specifying a local interface to use.

[Visual Basic]
' Connect to the server, specifying the local interface to use
Tcp1.Connect("atropos", 13, "192.168.0.83", 8888)

' Since connection was to DAYTIME port (13), simply receive the time
Dim seg As Segment = Tcp1.Receive()

Debug.WriteLine("Time reported by server: " + seg.ToString())
[C#]
// Connect to the server, specifying the local interface to use
tcp1.Connect("atropos", 13, "192.168.0.83", 8888);

// Since connection was to DAYTIME port (13), simply receive the time
Segment seg = tcp1.Receive();

Debug.WriteLine("Time reported by server: " + seg.ToString());

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Segment Class | Dart.PowerTCP.Telnet Namespace


Segment.Count Property

The amount of bytes that were sent/received.

[Visual Basic]
Public ReadOnly Property Count As Integer
[C#]
public int Count {get;}

Property Value

An integer value representing the amount of bytes that were sent/received.

Remarks

When using the Tcp component, using Tcp.Send or Tcp.Receive will return a Segment object. The amount of bytes transferred is available through Segment.Offset.

When using the Udp component, using Udp.Send or Udp.Receive will return a Datagram object. The amount of bytes transferred is available through Datagram.Offset.

When using other PowerTCP components, a Segment or Datagram object (which one depends on if TCP or UDP is used as the transport protocol) is made available to describe data sent or received, often in a Trace event. The Segment.Count or Datagram.Count property contains the amount of bytes transferred.

Example

[Visual Basic, C#] The following example demonstrates connecting to a server while specifying a local interface to use.

[Visual Basic]
' Connect to the server, specifying the local interface to use
Tcp1.Connect("atropos", 13, "192.168.0.83", 8888)

' Since connection was to DAYTIME port (13), simply receive the time
Dim seg As Segment = Tcp1.Receive()

Debug.WriteLine("Time reported by server: " + seg.ToString())
[C#]
// Connect to the server, specifying the local interface to use
tcp1.Connect("atropos", 13, "192.168.0.83", 8888);

// Since connection was to DAYTIME port (13), simply receive the time
Segment seg = tcp1.Receive();

Debug.WriteLine("Time reported by server: " + seg.ToString());

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Segment Class | Dart.PowerTCP.Telnet Namespace


Segment.Offset Property

The offset into the buffer.

[Visual Basic]
Public ReadOnly Property Offset As Integer
[C#]
public int Offset {get;}

Property Value

An integer representing the offset into the buffer.

Remarks

Use this property to access offset parameter of the Receive and Send methods.

When using the Tcp component, using Tcp.Send or Tcp.Receive will return a Segment object. The buffer offset is available through Segment.Offset.

When using the Udp component, using Udp.Send or Udp.Receive will return a Datagram object. The buffer offset is available through Datagram.Offset.

Use this property to properly access the data available in Segment.Buffer or Datagram.Buffer.

When using other PowerTCP components, a Segment or Datagram object (which one depends on if TCP or UDP is used as the transport protocol) is made available to describe data sent or received, often in a Trace event. The Segment.Offset or Datagram.Offset property contains the offset into the buffer.

Example

[Visual Basic, C#] The following example demonstrates connecting to a server while specifying a local interface to use.

[Visual Basic]
' Connect to the server, specifying the local interface to use
Tcp1.Connect("atropos", 13, "192.168.0.83", 8888)

' Since connection was to DAYTIME port (13), simply receive the time
Dim seg As Segment = Tcp1.Receive()

Debug.WriteLine("Time reported by server: " + seg.ToString())
[C#]
// Connect to the server, specifying the local interface to use
tcp1.Connect("atropos", 13, "192.168.0.83", 8888);

// Since connection was to DAYTIME port (13), simply receive the time
Segment seg = tcp1.Receive();

Debug.WriteLine("Time reported by server: " + seg.ToString());

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Segment Class | Dart.PowerTCP.Telnet Namespace


Segment.Sent Property

Indicates whether the data was sent or received.

[Visual Basic]
Public ReadOnly Property Sent As Boolean
[C#]
public bool Sent {get;}

Property Value

true if the data was sent, false otherwise.

Remarks

When using the Tcp component, all data sent or received with Tcp.Send or Tcp.Receive will return a Segment object. The Segment.Sent property indicates whether data was sent or received. If this property is true, then the Segment object was created because data was sent; false, the Segment object was created because data was received.

When using the Udp component, all data sent or received with Udp.Send or Udp.Receive will return a Datagram object. The Datagram.Sent property indicates whether data was sent or received. If this property is true, then the Datagram object was created because data was sent; false, the Datagram object was created because data was received.

When using other PowerTCP components, a Segment or Datagram object is made available to describe data sent or received, often in a Trace event. Access the Sent property to determine if the Trace event was raised because data was sent or received.

Example

[Visual Basic, C#] The following example demonstrates connecting to a server while specifying a local interface to use.

[Visual Basic]
' Connect to the server, specifying the local interface to use
Tcp1.Connect("atropos", 13, "192.168.0.83", 8888)

' Since connection was to DAYTIME port (13), simply receive the time
Dim seg As Segment = Tcp1.Receive()

Debug.WriteLine("Time reported by server: " + seg.ToString())
[C#]
// Connect to the server, specifying the local interface to use
tcp1.Connect("atropos", 13, "192.168.0.83", 8888);

// Since connection was to DAYTIME port (13), simply receive the time
Segment seg = tcp1.Receive();

Debug.WriteLine("Time reported by server: " + seg.ToString());

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Segment Class | Dart.PowerTCP.Telnet Namespace


Segment.SocketFlags Property

Gets the SocketFlags associated with the Segment.

[Visual Basic]
Public ReadOnly Property SocketFlags As SocketFlags
[C#]
public System.Net.Sockets.SocketFlags SocketFlags {get;}

Property Value

The SocketFlags associated with the Segment.

Remarks

Indicates the flags used when Tcp.Send or Tcp.Receive are used. See the SocketFlags topic within the MSDN documentation for more info.

See Also

Segment Class | Dart.PowerTCP.Telnet Namespace


Segment Methods

The methods of the Segment class are listed below. For a complete list of Segment class members, see the Segment Members topic.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString | Returns all data sent/received as a string.

See Also

Segment Class | Dart.PowerTCP.Telnet Namespace


Segment.ToString Method

Returns all data sent/received as a string.

[Visual Basic]
Overrides Public Function ToString() As String
[C#]
public override string ToString();

Return Value

A string representing all data sent or received.

Example

[Visual Basic, C#] The following example demonstrates connecting to a server while specifying a local interface to use.

[Visual Basic]
' Connect to the server, specifying the local interface to use
Tcp1.Connect("atropos", 13, "192.168.0.83", 8888)

' Since connection was to DAYTIME port (13), simply receive the time
Dim seg As Segment = Tcp1.Receive()

Debug.WriteLine("Time reported by server: " + seg.ToString())
[C#]
// Connect to the server, specifying the local interface to use
tcp1.Connect("atropos", 13, "192.168.0.83", 8888);

// Since connection was to DAYTIME port (13), simply receive the time
Segment seg = tcp1.Receive();

Debug.WriteLine("Time reported by server: " + seg.ToString());

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Segment Class | Dart.PowerTCP.Telnet Namespace


SegmentedStream Class

Used to provide advanced reading/writing capabilites to Stream-based objects.

For a list of all members of this type, see SegmentedStream Members.

System.Object
MarshalByRefObject
Stream
EnhancedStream
PipeStream
SegmentedStream

[Visual Basic]
Public Class SegmentedStream
Inherits PipeStream
[C#]
public class SegmentedStream : PipeStream

Remarks

SegmentedStream provides a way to read/write a segment of bytes to/from a backing store. To improve performance, SegmentedStream buffers reads and writes to the underlying stream and provides asynchronous read and write capability.

The SegmentedStream object is used within PowerTCP to read/write network data. The following examples further illustrate how SegmentedStream is used:

  • When using the Tcp or Telnet components, the TCP stream is exposed through the Object.Stream property (which is a SegmentedStream object). To write or read directly to the TCP stream, call Object.Stream.Read or Object.Stream.Write.
  • The SegmentedStream object is also used to access the TCP stream when using other Internet components as well. For example, when using the Ftp component, Ftp.Get or Ftp.Put can be called, making accessible a SegmentedStream object. SegmentedStream.Read and SegmentedStream.Write can then be called to read and write directly to the data connection.

Example

[Visual Basic, C#] The following example demonstrates connecting implementing the SMTP protocol using the Tcp component's stream interface to send a simple message.

[Visual Basic]
' The following code assumes that good responses are always received from
' the server. More robust code should check each response and handle appropriately.

' Connect to SMTP port
Tcp1.Connect("mail", 25)

' Send the EHLO command
Tcp1.Stream.Write("EHLO myserver\r\n")

' Get response from the server
Dim s As String = Tcp1.Stream.Read()

' Send MAIL FROM command
Tcp1.Stream.Write("MAIL FROM: test@dart.com" + vbCrLf)

' Get response from the server
s = Tcp1.Stream.Read()

' Send RCPT TO command
Tcp1.Stream.Write("RCPT TO: cranford@dart.com" + vbCrLf)

' Get response from the server
s = Tcp1.Stream.Read()

' Send DATA command
Tcp1.Stream.Write("DATA" + vbCrLf)

' Get response from the server
s = Tcp1.Stream.Read()

' Send DATA
Tcp1.Stream.Write("Test Message" + vbCrLf + "." + vbCrLf)

' Receive response from the server
s = Tcp1.Stream.Read()

' Write output
Debug.WriteLine("Operation complete. The following information")
Debug.WriteLine("was reported by the server:")
Debug.WriteLine(s)
[C#]
// The following code assumes that good responses are always received from
// the server. More robust code should check each response and handle appropriately.

// Connect to SMTP port
tcp1.Connect("mail", 25);

// Send the EHLO command
tcp1.Stream.Write("EHLO myserver\r\n");

// Get response from the server
string s = tcp1.Stream.Read();

// Send MAIL FROM command
tcp1.Stream.Write("MAIL FROM: test@dart.com\r\n");

// Get response from the server
s = tcp1.Stream.Read();

// Send RCPT TO command
tcp1.Stream.Write("RCPT TO: cranford@dart.com\r\n");

// Get response from the server
s = tcp1.Stream.Read();

// Send DATA command
tcp1.Stream.Write("DATA\r\n");

// Get response from the server
s = tcp1.Stream.Read();

// Send DATA
tcp1.Stream.Write("Test Message\r\n.\r\n");

// Receive response from the server
s = tcp1.Stream.Read();

// Write output
Debug.WriteLine("Operation complete. The following information");
Debug.WriteLine("was reported by the server:");
Debug.WriteLine(s);

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

SegmentedStream Members | Dart.PowerTCP.Telnet Namespace


SegmentedStream Members

SegmentedStream overview

Public Instance Constructors

SegmentedStream Overloaded. Initializes a new instance of the SegmentedStream class.

Public Instance Properties

Available | Gets the amount of bytes of data that has been received from the network and is available to be read.
CanRead | Indicates that data can be read from the stream.
CanSeek | Indicates that the stream can seek a specific location in the stream.
CanWrite | Indicates that data can be written to the stream.
Charset (inherited from EnhancedStream) | Gets and sets the character set used for string/byte array conversions.
CoreStream (inherited from PipeStream) | The internal stream to which all buffered reads/writes are being made.
Encoding (inherited from EnhancedStream) | Gets or sets the type of encoding to use.
Length (inherited from PipeStream) | Gets the length in bytes of the stream.
Position | Gets or sets the position in the stream.

Public Instance Methods

BeginRead | Overloaded. Begins an asychronous read from the stream that completes when the provided delimiter is found, count bytes have been read, or end of stream is reached.
BeginWrite (inherited from Stream) | Begins an asynchronous write operation.
Close | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from EnhancedStream) | Overloaded. Releases all resources associated with the object.
EndRead | Ends a pending asynchronous SegmentedStream.BeginRead request.
EndWrite (inherited from Stream) | Ends an asynchronous write operation.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Flush | Updates the underlying data source or repository with the current state of the buffer and then clears the buffer unless the internal Stream requires flushing..
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Read | Overloaded. Read data from the stream into a byte array.
Read (inherited from EnhancedStream) | Overloaded. When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
ReadByte (inherited from Stream) | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
Save (inherited from EnhancedStream) | Overloaded. Saves the data in the stream to the file specified by fileName.
Seek | Seeks a specific position in the stream.
SetLength | Sets the length of the Stream. This method always throws a NotSupportedException.
ToArray (inherited from EnhancedStream) | Returns the byte array representation of the Stream data.
ToString (inherited from EnhancedStream) | Returns the string representation of the Stream data.
Write | Overloaded. Writes data to the stream.
Write (inherited from EnhancedStream) | Overloaded. When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
WriteByte (inherited from Stream) | Writes a byte to the current position in the stream and advances the position within the stream by one byte.
WriteTo (inherited from EnhancedStream) | Overloaded. Writes all of the data contained in this Stream to a destination Stream.

Public Instance Events

Trace

Explicit Interface Implementations

IDisposable.Dispose (inherited from Stream)

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace


SegmentedStream Constructor

Initializes a new instance of the SegmentedStream class for the specified stream object.

Overload List

Initializes a new instance of the SegmentedStream class for the specified stream object.

public SegmentedStream(Stream);

Initializes a new instance of the SegmentedStream class for the specified stream object.

public SegmentedStream(Stream,Encoding);

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace


SegmentedStream Constructor (Stream)

Initializes a new instance of the SegmentedStream class for the specified stream object.

[Visual Basic]
Overloads Public Sub New( _
ByVal stream As Stream _
)
[C#]
public SegmentedStream(
Stream stream
);

Parameters

stream
The source stream to Read/Write.

Remarks

Although any type of stream can be used to initialize a SegmentedStream (a FileStream or a MemoryStream, for example) the intented use is to initialize a SegmentedStream with some form of network stream (such as a TcpStream). You will not usually need to create a SegmentedStream object, as the SegmentedStream object currently accessing the TCP stream is made accessible (either as a property of the component, or as an object accessible in an event or returned from a method). For example, if you wish to send/receive data to/from a server using a stream interface, simply use Tcp.Connect to connect to the server and call Tcp.Stream.Write or Tcp.Stream.Read to send/receive data.

Example

[Visual Basic, C#] The following example demonstrates initializing a new instance of a SegmentedStream object to a TcpStream.

[Visual Basic]
' Connect to a server
Tcp1.Connect("atropos", 7)

' Initialize a SegmentedStream to the NetworkStream
Dim sstream As New SegmentedStream(new TcpStream(Tcp1))

' Send data
sstream.Write("hello")

' Receive data
Dim s As String = sstream.Read()
[C#]
// Connect to a server
tcp1.Connect("atropos", 7);

// Initialize a SegmentedStream to the NetworkStream
SegmentedStream sstream = new SegmentedStream(new TcpStream(tcp1));

// Send data
sstream.Write("hello");

// Receive data
string s = sstream.Read();

[C++, JScript] No example is available for C++ and JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace | SegmentedStream Constructor Overload List


SegmentedStream Constructor (Stream, Encoding)

Initializes a new instance of the SegmentedStream class for the specified stream object.

[Visual Basic]
Overloads Public Sub New( _
ByVal stream As Stream, _
ByVal encoding As Encoding _
)
[C#]
public SegmentedStream(
Stream stream,
Encoding encoding
);

Parameters

stream
The source stream to Read/Write.
encoding
The encoding type to use when working with strings.

Remarks

Although any type of stream can be used to initialize a SegmentedStream (a FileStream or a MemoryStream, for example) the intented use is to initialize a SegmentedStream with some form of network stream (such as a TcpStream). You will not usually need to create a SegmentedStream object, as the SegmentedStream object currently accessing the TCP stream is made accessible (either as a property of the component, or as an object accessible in an event or returned from a method). For example, if you wish to send/receive data to/from a server using a stream interface, simply use Tcp.Connect to connect to the server and call Tcp.Stream.Write or Tcp.Stream.Read to send/receive data.

Example

[Visual Basic, C#] The following example demonstrates initializing a new instance of a SegmentedStream object to a TcpStream.

[Visual Basic]
' Connect to a server
Tcp1.Connect("atropos", 7)

' Initialize a SegmentedStream to the NetworkStream
Dim sstream As New SegmentedStream(new TcpStream(Tcp1))

' Send data
sstream.Write("hello")

' Receive data
Dim s As String = sstream.Read()
[C#]
// Connect to a server
tcp1.Connect("atropos", 7);

// Initialize a SegmentedStream to the NetworkStream
SegmentedStream sstream = new SegmentedStream(new TcpStream(tcp1));

// Send data
sstream.Write("hello");

// Receive data
string s = sstream.Read();

[C++, JScript] No example is available for C++ and JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace | SegmentedStream Constructor Overload List


SegmentedStream Properties

The properties of the SegmentedStream class are listed below. For a complete list of SegmentedStream class members, see the SegmentedStream Members topic.

Public Instance Properties

Available | Gets the amount of bytes of data that has been received from the network and is available to be read.
CanRead | Indicates that data can be read from the stream.
CanSeek | Indicates that the stream can seek a specific location in the stream.
CanWrite | Indicates that data can be written to the stream.
Charset (inherited from EnhancedStream) | Gets and sets the character set used for string/byte array conversions.
CoreStream (inherited from PipeStream) | The internal stream to which all buffered reads/writes are being made.
Encoding (inherited from EnhancedStream) | Gets or sets the type of encoding to use.
Length (inherited from PipeStream) | Gets the length in bytes of the stream.
Position | Gets or sets the position in the stream.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace


SegmentedStream.Available Property

Gets the amount of bytes of data that has been received from the network and is available to be read.

[Visual Basic]
Public ReadOnly Property Available As Integer
[C#]
public int Available {get;}

Remarks

A positive number indicates that data has been received from the network. Call SegmentedStream.Read to access this data. 0 indicates that no data is available to be read.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace


SegmentedStream.CanRead Property

Indicates that data can be read from the stream.

[Visual Basic]
Overrides Public ReadOnly Property CanRead As Boolean
[C#]
public override bool CanRead {get;}

Remarks

If the stream is closed, this property returns false.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace


SegmentedStream.CanSeek Property

Indicates that the stream can seek a specific location in the stream.

[Visual Basic]
Overrides Public ReadOnly Property CanSeek As Boolean
[C#]
public override bool CanSeek {get;}

Remarks

This property always returns false.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace


SegmentedStream.CanWrite Property

Indicates that data can be written to the stream.

[Visual Basic]
Overrides Public ReadOnly Property CanWrite As Boolean
[C#]
public override bool CanWrite {get;}

Remarks

If the stream is closed, this property returns false.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace


SegmentedStream.Position Property

Gets or sets the position in the stream.

[Visual Basic]
Overrides Public Property Position As Long
[C#]
public override long Position {get; set;}

Remarks

Returns the value of CoreStream.Position. If a Tcp socket is the source of the stream, then a NotSupportedException is thrown.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace


SegmentedStream Methods

The methods of the SegmentedStream class are listed below. For a complete list of SegmentedStream class members, see the SegmentedStream Members topic.

Public Instance Methods

BeginRead | Overloaded. Begins an asychronous read from the stream that completes when the provided delimiter is found, count bytes have been read, or end of stream is reached.
BeginWrite (inherited from Stream) | Begins an asynchronous write operation.
Close | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from EnhancedStream) | Overloaded. Releases all resources associated with the object.
EndRead | Ends a pending asynchronous SegmentedStream.BeginRead request.
EndWrite (inherited from Stream) | Ends an asynchronous write operation.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Flush | Updates the underlying data source or repository with the current state of the buffer and then clears the buffer unless the internal Stream requires flushing..
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Read | Overloaded. Read data from the stream into a byte array.
Read (inherited from EnhancedStream) | Overloaded. When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
ReadByte (inherited from Stream) | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
Save (inherited from EnhancedStream) | Overloaded. Saves the data in the stream to the file specified by fileName.
Seek | Seeks a specific position in the stream.
SetLength | Sets the length of the Stream. This method always throws a NotSupportedException.
ToArray (inherited from EnhancedStream) | Returns the byte array representation of the Stream data.
ToString (inherited from EnhancedStream) | Returns the string representation of the Stream data.
Write | Overloaded. Writes data to the stream.
Write (inherited from EnhancedStream) | Overloaded. When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
WriteByte (inherited from Stream) | Writes a byte to the current position in the stream and advances the position within the stream by one byte.
WriteTo (inherited from EnhancedStream) | Overloaded. Writes all of the data contained in this Stream to a destination Stream.

Explicit Interface Implementations

IDisposable.Dispose (inherited from Stream)

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace


BeginRead Method

PowerTCP Telnet for .NET

SegmentedStream.BeginRead Method

Begins an asychronous read from the stream that completes when the provided delimiter is found, count bytes have been read, or end of stream is reached.

Overload List

Begins an asychronous read from the stream that completes when the provided delimiter is found, count bytes have been read, or end of stream is reached.

public virtual IAsyncResult BeginRead(byte[],byte[],int,int,ref bool,AsyncCallback,object);

Begins an asychronous read from the stream that complete when at least one byte is read. This operation reads at most count bytes.

public override IAsyncResult BeginRead(byte[],int,int,AsyncCallback,object);

Begins an asychronous read from the stream that completes when the provided buffer is completely full, the number of bytes requested is read, or end of stream is reached.

public virtual IAsyncResult BeginRead(byte[],int,int,bool,AsyncCallback,object);

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace


SegmentedStream.BeginRead Method (Byte[], Byte[], Int32, Int32, Boolean, AsyncCallback, Object)

Begins an asychronous read from the stream that completes when the provided delimiter is found, count bytes have been read, or end of stream is reached.

[Visual Basic]
Overridable Overloads Public Function BeginRead( _
ByVal buffer As Byte(), _
ByVal delimiter As Byte(), _
ByVal offset As Integer, _
ByVal count As Integer, _
ByRef found As Boolean, _
ByVal callback As AsyncCallback, _
ByVal state As Object _
) As IAsyncResult
[C#]
public virtual IAsyncResult BeginRead(
byte[] buffer,
byte[] delimiter,
int offset,
int count,
ref bool found,
AsyncCallback callback,
object state
);

Parameters

buffer
The storage location for the received data.
delimiter
The token that is used to determine a segment was read.
offset
The zero-based position in the buffer at which to store the received data.
count
The maximum number of bytes to read.
found
callback
The AsyncCallback delegate to be called when the operation is complete.
state
An object containing state information for this operation.

Return Value

An IAsyncResult representing the asynchronous operation. To determine how many bytes were read, you must pass this IAsyncResult to the EndRead method of the stream. This should be done within your AsyncCallback event handler.

Remarks

The purpose of this method is to provide a convenient way to read a variable-length record from the stream. The EndRead method should be called when your AsyncCallback delegate is raised.

Exceptions

Exception Type | Condition
IOException | Thrown when the stream is not Readable.
ArgumentNullException | Thrown when the buffer, delimiter or callback is null.
ArgumentOutOfRangeException | Thrown when the offset is less than zero or when count is less than or equal to zero.
ArgumentException | Thrown when the (offset + count) > buffer.Length, or delimiter.Length == 0, or delimiter.length > count.

Example

[C#] The following example demonstrates asynchronously reading from the server using the stream interface. This involves creating a callback method in which the response is handled. If you would like to use fully asynchronous methods with events already implemented, try the low-level interface (Tcp.BeginRead & Tcp.BeginWrite).

[C#]
private void AsynchronousReadTest()
{
   // Connect to the server
   tcp1.Connect("atropos", 13);

   // DAYTIME protocol (port 13) sends data and closes, receive data.
   // This demonstrates receiving data asynchronously using the stream interface.

   // data buffer is a global variable
   databuffer = new byte[tcp1.ReceiveBufferSize];

   // Begin the asynchronous Read operation.
   tcp1.Stream.BeginRead(databuffer, 0, tcp1.ReceiveBufferSize, new System.AsyncCallback(MyCallback), null);
}

private void MyCallback(System.IAsyncResult ar)
{
   // End pending asynchronous request.
   if(ar.IsCompleted)
      tcp1.Stream.EndRead(ar);

   // Write result
   Debug.WriteLine(System.Text.Encoding.Default.GetString(databuffer));
}

[Visual Basic, C++, JScript] No example is available for Visual Basic, C++ or JScript. To view a C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace | SegmentedStream.BeginRead Overload List


SegmentedStream.BeginRead Method (Byte[], Int32, Int32, AsyncCallback, Object)

Begins an asychronous read from the stream that complete when at least one byte is read. This operation reads at most count bytes.

[Visual Basic]
Overrides Overloads Public Function BeginRead( _
ByVal buffer As Byte(), _
ByVal offset As Integer, _
ByVal count As Integer, _
ByVal callback As AsyncCallback, _
ByVal state As Object _
) As IAsyncResult
[C#]
public override IAsyncResult BeginRead(
byte[] buffer,
int offset,
int count,
AsyncCallback callback,
object state
);

Parameters

buffer
The storage location for the received data.
offset
The zero-based position in the buffer at which to store the received data.
count
The maximum number of bytes to read.
callback
The AsyncCallback delegate to be called when the operation is complete.
state
An object containing state information for this operation.

Return Value

An IAsyncResult representing the asynchronous operation. To determine how many bytes were read, you must pass this IAsyncResult to the EndRead method of the stream. This should be done within your AsyncCallback event handler.

Remarks

This is the standard method to use when reading a stream asynchronously. If a fixed-length record buffer is being read, use the overloaded Read() method that includes the 'bool fill' parameter. If a variable-length record segment is being read, use the overloaded Read() method that includes the 'byte[] delimiter' parameter.

Exceptions

Exception Type | Condition
IOException | Thrown when the stream is not Readable.
ArgumentNullException | Thrown when the buffer or callback is null.
ArgumentOutOfRangeException | Thrown when the offset is less than zero or when count is less than or equal to zero.
ArgumentException | Thrown when the (offset + count) > buffer.Length.

Example

[C#] The following example demonstrates asynchronously reading from the server using the stream interface. This involves creating a callback method in which the response is handled. If you would like to use fully asynchronous methods with events already implemented, try the low-level interface (Tcp.BeginRead & Tcp.BeginWrite).

[C#]
private void AsynchronousReadTest()
{
   // Connect to the server
   tcp1.Connect("atropos", 13);

   // DAYTIME protocol (port 13) sends data and closes, receive data.
   // This demonstrates receiving data asynchronously using the stream interface.

   // data buffer is a global variable
   databuffer = new byte[tcp1.ReceiveBufferSize];

   // Begin the asynchronous Read operation.
   tcp1.Stream.BeginRead(databuffer, 0, tcp1.ReceiveBufferSize, new System.AsyncCallback(MyCallback), null);
}

private void MyCallback(System.IAsyncResult ar)
{
   // End pending asynchronous request.
   if(ar.IsCompleted)
      tcp1.Stream.EndRead(ar);

   // Write result
   Debug.WriteLine(System.Text.Encoding.Default.GetString(databuffer));
}

[Visual Basic, C++, JScript] No example is available for Visual Basic, C++ or JScript. To view a C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace | SegmentedStream.BeginRead Overload List


SegmentedStream.BeginRead Method (Byte[], Int32, Int32, Boolean, AsyncCallback, Object)

Begins an asychronous read from the stream that completes when the provided buffer is completely full, the number of bytes requested is read, or end of stream is reached.

[Visual Basic]
Overridable Overloads Public Function BeginRead( _
ByVal buffer As Byte(), _
ByVal offset As Integer, _
ByVal count As Integer, _
ByVal fill As Boolean, _
ByVal callback As AsyncCallback, _
ByVal state As Object _
) As IAsyncResult
[C#]
public virtual IAsyncResult BeginRead(
byte[] buffer,
int offset,
int count,
bool fill,
AsyncCallback callback,
object state
);

Parameters

buffer
The storage location for the received data.
offset
The zero-based position in the buffer at which to store the received data.
count
The exact number of bytes to read.
fill
Always true, use this version of BeginRead to completely fill the buffer
callback
The AsyncCallback delegate to be called when the operation is complete.
state
An object containing state information for this operation.

Return Value

An IAsyncResult representing the asynchronous operation. To determine how many bytes were read, you must pass this IAsyncResult to the EndRead method of the stream. This should be done within your AsyncCallback event handler.

Remarks

The purpose of this method is to provide a convenient way to read a fixed-length record from the stream. The EndRead method should be called when your AsyncCallback delegate is raised.

Exceptions

Exception Type | Condition
IOException | Thrown when the stream is not Readable.
ArgumentNullException | Thrown when the buffer or callback is null.
ArgumentOutOfRangeException | Thrown when the offset is less than zero or when count is less than or equal to zero.
ArgumentException | Thrown when the (offset + count) > (buffer.Length).

Example

[C#] The following example demonstrates asynchronously reading from the server using the stream interface. This involves creating a callback method in which the response is handled. If you would like to use fully asynchronous methods with events already implemented, try the low-level interface (Tcp.BeginRead & Tcp.BeginWrite).

[C#]
private void AsynchronousReadTest()
{
   // Connect to the server
   tcp1.Connect("atropos", 13);

   // DAYTIME protocol (port 13) sends data and closes, receive data.
   // This demonstrates receiving data asynchronously using the stream interface.

   // data buffer is a global variable
   databuffer = new byte[tcp1.ReceiveBufferSize];

   // Begin the asynchronous Read operation.
   tcp1.Stream.BeginRead(databuffer, 0, tcp1.ReceiveBufferSize, new System.AsyncCallback(MyCallback), null);
}

private void MyCallback(System.IAsyncResult ar)
{
   // End pending asynchronous request.
   if(ar.IsCompleted)
      tcp1.Stream.EndRead(ar);

   // Write result
   Debug.WriteLine(System.Text.Encoding.Default.GetString(databuffer));
}

[Visual Basic, C++, JScript] No example is available for Visual Basic, C++ or JScript. To view a C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace | SegmentedStream.BeginRead Overload List


SegmentedStream.Close Method

Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream.

[Visual Basic]
Overrides Public Sub Close()
[C#]
public override void Close();

Remarks

This method closes the SegmentedStream and frees resources associated with the SegmentedStream.

Exceptions

Exception Type | Condition
ObjectDisposedException | A member was accessed while the stream was closed.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace


SegmentedStream.EndRead Method

Ends a pending asynchronous SegmentedStream.BeginRead request.

[Visual Basic]
Overrides Public Function EndRead( _
ByVal ar As IAsyncResult _
) As Integer
[C#]
public override int EndRead(
IAsyncResult ar
);

Parameters

ar
Reference to the pending asynchronous request that is returned from BeginRead().

Return Value

The number of bytes read from the stream and copied into the user's buffer. Will return 0 at the end of the stream to indicate the stream has closed and all data has been read.

Remarks

You will normally call this method from within your AsyncCallback event handler to complete your asynchronous read request, but it can be called anytime to cancel an outstanding request.

Exceptions

Exception Type | Condition
IOException | Thrown when the stream is not Readable.
ArgumentNullException | asyncResult is a null reference.
ArgumentException | asyncResult is not a valid reference.
EndOfStreamException | The end of the stream was found before the required byte count was received, or the end of the stream was found before the delimiter was found.
InternalBufferOverflowException | The delimiter was not found within the maximum number of bytes (count) specified.

Example

[C#] The following example demonstrates asynchronously reading from the server using the stream interface. This involves creating a callback method in which the response is handled. If you would like to use fully asynchronous methods with events already implemented, try the low-level interface (Tcp.BeginRead & Tcp.BeginWrite).

[C#]
private void AsynchronousReadTest()
{
   // Connect to the server
   tcp1.Connect("atropos", 13);

   // DAYTIME protocol (port 13) sends data and closes, receive data.
   // This demonstrates receiving data asynchronously using the stream interface.

   // data buffer is a global variable
   databuffer = new byte[tcp1.ReceiveBufferSize];

   // Begin the asynchronous Read operation.
   tcp1.Stream.BeginRead(databuffer, 0, tcp1.ReceiveBufferSize, new System.AsyncCallback(MyCallback), null);
}

private void MyCallback(System.IAsyncResult ar)
{
   // End pending asynchronous request.
   if(ar.IsCompleted)
      tcp1.Stream.EndRead(ar);

   // Write result
   Debug.WriteLine(System.Text.Encoding.Default.GetString(databuffer));
}

[Visual Basic, C++, JScript] No example is available for Visual Basic, C++ or JScript. To view a C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace


SegmentedStream.Flush Method

Updates the underlying data source or repository with the current state of the buffer and then clears the buffer unless the internal Stream requires flushing..

[Visual Basic]
Overrides Public Sub Flush()
[C#]
public override void Flush();

Remarks

All the read and write methods of SegmentedStream automatically maintain the buffer, so there is no need to invoke Flush when switching back and forth between reading and writing.

Example

[Visual Basic, C#] The following example demonstrates writing data until a delimiter is reached.

[Visual Basic]
' Create test data
Dim buffer As Byte() = System.Text.Encoding.Default.GetBytes("acbdefghijklmnopqrstuvwxyz" + vbCrLf)
Dim delimiter As Byte() = System.Text.Encoding.Default.GetBytes("ghi")

Dim offset As Integer = 0
Dim count As Integer = buffer.Length

' Connect to echo port
Tcp1.Connect("atropos", 7)

' Send data until the delimiter is reached.
Dim found As Boolean = Tcp1.Stream.Write(buffer, delimiter, offset, count)

' Flush the rest of the data
Tcp1.Stream.Flush()

' Recieve data.
Dim s As String = Tcp1.Stream.Read()

Debug.WriteLine(s)

'* Output
'* -----------------------
'* abcdef
[C#]
// Create test data
byte[] buffer = System.Text.Encoding.Default.GetBytes("acbdefghijklmnopqrstuvwxyz\r\n");
byte[] delimiter = System.Text.Encoding.Default.GetBytes("ghi");
int offset = 0;
int count = buffer.Length;

// Connect to echo port
tcp1.Connect("atropos", 7);

// Send data until the delimiter is reached.
bool found = tcp1.Stream.Write(buffer, delimiter, ref offset, ref count);

// Flush the rest of the data
tcp1.Stream.Flush();

// Recieve data.
string s = tcp1.Stream.Read();

Debug.WriteLine(s);

/* Output
 * -----------------------
 * abcdef
 */

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace


Read Method

PowerTCP Telnet for .NET

SegmentedStream.Read Method

Read data from the stream into a string.

Overload List

Read data from the stream into a string.

public string Read();

Inherited from EnhancedStream.

public int Read(byte[]);

Read data from the stream until a byte array is filled.

public int Read(byte[],bool);

Read data from the stream until a delimiter is reached.

public int Read(byte[],byte[],ref bool);

Read data from the stream.

public int Read(byte[],byte[],int,int,ref bool);

Read data from the stream into a byte array.

public override int Read(byte[],int,int);

Read data from the stream until a byte array is filled.

public int Read(byte[],int,int,bool);

Read data from the stream into a string.

public string Read(int);

Reads stream, accumulating string data, until delimiter is reached or timeout is reached.

public string Read(string);

Read data from the stream until a delimiter is reached.

public string Read(string,int,ref bool);

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace


SegmentedStream.Read Method ()

Read data from the stream into a string.

[Visual Basic]
Overloads Public Function Read() As String
[C#]
public string Read();

Return Value

A string containing the data read from the stream.

Remarks

This method will block (for ReceiveTimeout) until at least 1 byte is available for reading, or the connection is closed by the server, in which case an empty string is returned. The Charset property is used to convert from bytes to unicode characters, which allows unicode characters to be passed over the network.

Exceptions

Exception Type | Condition
IOException | Thrown when the stream is not Readable.
ArgumentNullException | Thrown when the receiving buffer is null.
ArgumentOutOfRangeException | Thrown when the offset is less than zero or when count is less than or equal to zero.
ArgumentException | Thrown when (offset + count) > buffer.Length.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace | SegmentedStream.Read Overload List


SegmentedStream.Read Method (Byte[], Int32, Int32, Boolean)

Read data from the stream until a byte array is filled.

[Visual Basic]
Overloads Public Function Read( _
ByVal buffer As Byte(), _
ByVal offset As Integer, _
ByVal count As Integer, _
ByVal fill As Boolean _
) As Integer
[C#]
public int Read(
byte[] buffer,
int offset,
int count,
bool fill
);

Parameters

buffer
The storage location for the received data.
offset
The zero-based position in the buffer at which to store the received data.
count
The exact number of bytes to read.
fill
Always true, use this version of Read to completely fill the buffer

Return Value

The total number of bytes read into the buffer. This will either be the value of the count parameter, or zero if the stream has closed.

Remarks

This method reads data from the stream and returns when the provided buffer is completely full or end of stream is reached. This method is a good way to read fixed-length data. An example of this is with HTTP chunking, which occurs when the server breaks up the HTTP response into fixed-size chunks. Each chunk is preceded with a hexidecimal value notifying the receiver of the size of the data chunk to follow. Initialize a byte array to this value, then call this method to fill the byte array.

Exceptions

Exception Type | Condition
IOException | Thrown when the stream is not Readable.
ArgumentNullException | Thrown when the receiving buffer is null.
ArgumentOutOfRangeException | Thrown when the offset is less than zero or when count is less than or equal to zero.
ArgumentException | Thrown when (offset + count) > buffer.Length.
EndOfStreamException | Thrown when the end of the stream was found before the required byte count was received. When this occurs the Available property will indicate how much data may be read and the CanRead Property will return true.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace | SegmentedStream.Read Overload List


SegmentedStream.Read Method (Byte[], Byte[], Int32, Int32, Boolean)

Read data from the stream.

[Visual Basic]
Overloads Public Function Read( _
ByVal buffer As Byte(), _
ByVal delimiter As Byte(), _
ByVal offset As Integer, _
ByVal count As Integer, _
ByRef found As Boolean _
) As Integer
[C#]
public int Read(
byte[] buffer,
byte[] delimiter,
int offset,
int count,
ref bool found
);

Parameters

buffer
The storage location for the received data.
delimiter
The token that is used to determine a segment was read.
offset
The zero-based position in the buffer at which to store the received data.
count
The maximum number of bytes to read.
found
True if delimiter is found; false otherwise.

Return Value

The total number of bytes read into the buffer, which will normally be less than count. Returns 0 if end of stream is reached and there is no data left to return.

Remarks

This method reads from the stream and returns when the provided delimiter is found, count bytes have been read, or end of stream is reached.

The purpose of this method is to provide a convenient way to read a variable-length record from the stream. This is the only kind of Read that uses internal buffering.

If the delimiter is found, found is true, otherwise found is false.

Exceptions

Exception Type | Condition
IOException | Thrown when the stream is not readable.
ArgumentNullException | Thrown when the receiving buffer is null.
ArgumentOutOfRangeException | Thrown when the offset is less than zero or when count is less than or equal to zero.
ArgumentException | Thrown when (offset + count) > buffer.Length.
EndOfStreamException | At least one byte was read without finding the delimiter before end of stream was reached.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace | SegmentedStream.Read Overload List


SegmentedStream.Read Method (Byte[], Boolean)

Read data from the stream until a byte array is filled.

[Visual Basic]
Overloads Public Function Read( _
ByVal buffer As Byte(), _
ByVal fill As Boolean _
) As Integer
[C#]
public int Read(
byte[] buffer,
bool fill
);

Parameters

buffer
The storage location for the received data.
fill
Always true, use this version of Read to completely fill the buffer

Return Value

The total number of bytes read into the buffer. This will either be the value of the count parameter, or zero if the stream has closed.

Remarks

This method reads data from the stream and returns when the provided buffer is completely full or end of stream is reached. This method is a good way to read fixed-length data. An example of this is with HTTP chunking, which occurs when the server breaks up the HTTP response into fixed-size chunks. Each chunk is preceded with a hexidecimal value notifying the receiver of the size of the data chunk to follow. Initialize a byte array to this value, then call this method to fill the byte array.

Exceptions

Exception Type | Condition
IOException | Thrown when the stream is not Readable.
ArgumentNullException | Thrown when the receiving buffer is null.
EndOfStreamException | Thrown when the end of the stream was found before the required byte count was received. When this occurs the Available property will indicate how much data may be read and the CanRead Property will return true.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace | SegmentedStream.Read Overload List


SegmentedStream.Read Method (Byte[], Int32, Int32)

Read data from the stream into a byte array.

[Visual Basic]
Overrides Overloads Public Function Read( _
ByVal buffer As Byte(), _
ByVal offset As Integer, _
ByVal count As Integer _
) As Integer
[C#]
public override int Read(
byte[] buffer,
int offset,
int count
);

Parameters

buffer
The storage location for the received data.
offset
The zero-based position in the buffer at which to store the received data.
count
The maximum number of bytes to read.

Return Value

The total number of bytes read into the buffer.

Remarks

This method will block (for ReceiveTimeout) until at least 1 byte is available for reading, or the connection is closed by the server, in which case an empty string is returned. The Charset property is used to convert from bytes to unicode characters, which allows unicode characters to be passed over the network.

The value returned may be less than the number of bytes requested if that many bytes are not currently available, or zero if the end of the stream has been reached. Applications must check this value to know how many bytes were read into the buffer.

Exceptions

Exception Type | Condition
IOException | Thrown when the stream is not Readable.
ArgumentNullException | Thrown when the receiving buffer is null.
ArgumentOutOfRangeException | Thrown when the offset is less than zero or when count is less than or equal to zero.
ArgumentException | Thrown when the (offset + count) > buffer.Length.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace | SegmentedStream.Read Overload List


SegmentedStream.Read Method (String)

Reads stream, accumulating string data, until delimiter is reached or timeout is reached.

[Visual Basic]
Overloads Public Function Read( _
ByVal delimiter As String _
) As String
[C#]
public string Read(
string delimiter
);

Parameters

delimiter
The sequence to find.

Return Value

The accumulated string data read from the stream.

Remarks

This method is useful when implementing high-level protocols.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace | SegmentedStream.Read Overload List


SegmentedStream.Read Method (Int32)

Read data from the stream into a string.

[Visual Basic]
Overloads Public Function Read( _
ByVal size As Integer _
) As String
[C#]
public string Read(
int size
);

Parameters

size
This method reads a buffer from the Stream of up to size count.

Return Value

A string value representing the data read from the stream.

Remarks

This method reads data from the stream until at least 1 byte has been read or the end of the stream has been reached.

Exceptions

Exception Type | Condition
IOException | Thrown when the stream is not Readable.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace | SegmentedStream.Read Overload List


SegmentedStream.Read Method (String, Int32, Boolean)

Read data from the stream until a delimiter is reached.

[Visual Basic]
Overloads Public Function Read( _
ByVal delimiter As String, _
ByVal size As Integer, _
ByRef found As Boolean _
) As String
[C#]
public string Read(
string delimiter,
int size,
ref bool found
);

Parameters

delimiter
The sequence to find.
size
The size of the buffer to be created.
found
Will be set to true if sequence is found; false otherwise.

Return Value

A string representation of the bytes read.

Remarks

This method reads data from the stream until delimiter is found or the end of the stream is reached.

This method is useful for reading until a sequence of characters is found. A good example of this is receiving an email message when using the POP protocol. When sending a POP mail message, a POP server will delimit the end of the message with <CRLF>.<CRLF>. Using this method you could simply read the data until this sequence is found, at which point the method would return.

If the delimiter is found, found is true, otherwise found is false.

Exceptions

Exception Type | Condition
IOException | Thrown when the stream is not Readable.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace | SegmentedStream.Read Overload List


SegmentedStream.Seek Method

Seeks a specific position in the stream.

[Visual Basic]
Overrides Public Function Seek( _
ByVal offset As Long, _
ByVal origin As SeekOrigin _
) As Long
[C#]
public override long Seek(
long offset,
SeekOrigin origin
);

Parameters

offset
A byte offset relative to origin.
origin
A value of type SeekOrigin indicating the reference point used to obtain the new position.

Return Value

The number of bytes that were seeked past.

Remarks

Returns value of CoreStream.Seek. TcpStream.Seek throws a NotSupportedException.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace


SegmentedStream.SetLength Method

Sets the length of the Stream. This method always throws a NotSupportedException.

[Visual Basic]
Overrides Public Sub SetLength( _
ByVal value As Long _
)
[C#]
public override void SetLength(
long value
);

Parameters

value
The desired length of the current stream in bytes.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace


Write Method

PowerTCP Telnet for .NET

SegmentedStream.Write Method

Write data to the stream while carrying out a bytewise find/replace.

Overload List

Inherited from EnhancedStream.

public void Write(byte[]);

Write data to the stream while carrying out a bytewise find/replace.

public void Write(byte[],byte[],byte[],int,int);

Write data to the stream until a delimiter is reached.

public bool Write(byte[],byte[],ref int,ref int);

Writes data to the stream.

public override void Write(byte[],int,int);

Write a string to the stream.

public void Write(string);

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace


SegmentedStream.Write Method (Byte[], Byte[], Byte[], Int32, Int32)

Write data to the stream while carrying out a bytewise find/replace.

[Visual Basic]
Overloads Public Sub Write( _
ByVal buffer As Byte(), _
ByVal originalSequence As Byte(), _
ByVal replacementSequence As Byte(), _
ByVal offset As Integer, _
ByVal count As Integer _
)
[C#]
public void Write(
byte[] buffer,
byte[] originalSequence,
byte[] replacementSequence,
int offset,
int count
);

Parameters

buffer
The storage location of the data.
originalSequence
The sequence to find.
replacementSequence
The sequence to replace.
offset
The zero-based position in the buffer from which to begin writing from.
count
The number of bytes from buffer that should be processed using the byte replacement desired.

Remarks

Carries out a bytewise find/replace of all occurances found in buffer of originalSequence with replacementSequence. This method is useful for performing simple encoding of data before sending.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace | SegmentedStream.Write Overload List


SegmentedStream.Write Method (Byte[], Byte[], Int32, Int32)

Write data to the stream until a delimiter is reached.

[Visual Basic]
Overloads Public Function Write( _
ByVal buffer As Byte(), _
ByVal delimiter As Byte(), _
ByRef offset As Integer, _
ByRef count As Integer _
) As Boolean
[C#]
public bool Write(
byte[] buffer,
byte[] delimiter,
ref int offset,
ref int count
);

Parameters

buffer
The storage location of the data.
delimiter
The sequence to find.
offset
The zero-based position in the buffer from which to begin writing from.
count
The exact number of bytes to write.

Return Value

true if delimiter is found; false otherwise.

Remarks

This method writes data until the delimiter is found (returning true and not writing the delimiter) or writes the entire buffer (returning false).

Flush must be called after writing if this method is being used.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace | SegmentedStream.Write Overload List


SegmentedStream.Write Method (Byte[], Int32, Int32)

Writes data to the stream.

[Visual Basic]
Overrides Overloads Public Sub Write( _
ByVal buffer As Byte(), _
ByVal offset As Integer, _
ByVal count As Integer _
)
[C#]
public override void Write(
byte[] buffer,
int offset,
int count
);

Parameters

buffer
The storage location of the data to be sent.
offset
The zero-based position in the buffer from which to begin writing from.
count
The exact number of bytes to write.

Remarks

This method writes a sequence of bytes to the stream and returns when the operation is complete.

Use the CanWrite property to determine whether the current instance supports writing.

Exceptions

Exception Type | Condition
IOException | Thrown when the stream is not Writeable.
ArgumentNullException | Thrown when buffer is null.
ArgumentOutOfRangeException | Thrown when the offset is less than zero or when count is less than or equal to zero.
ArgumentException | Thrown when the (offset + count) > buffer.Length.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace | SegmentedStream.Write Overload List


SegmentedStream.Write Method (String)

Write a string to the stream.

[Visual Basic]
Overloads Public Sub Write( _
ByVal buffer As String _
)
[C#]
public void Write(
string buffer
);

Parameters

buffer
The storage location of the data to be sent.

Remarks

This method writes a string to the stream and returns from complete. Since this method writes a string (doing a byte array conversion behind-the-scenes using the Object.Charset to convert unicode characters to bytes) to the stream, it is useful for such purposes as sending protocol commands to a server.

Use the CanWrite property to determine whether the current instance supports writing.

Exceptions

Exception Type | Condition
IOException | Thrown when the stream is not Writeable.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace | SegmentedStream.Write Overload List


SegmentedStream Events

The events of the SegmentedStream class are listed below. For a complete list of SegmentedStream class members, see the SegmentedStream Members topic.

Public Instance Events

Trace

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace


SegmentedStream.Trace Event

[Visual Basic]
Public Event Trace As SegmentEventHandler
[C#]
public event SegmentEventHandler Trace;

Event Data

The event handler receives an argument of type SegmentEventArgs containing data related to this event. The following SegmentEventArgs properties provide information specific to this event.

Property | Description
Exception | Gets any exception which occurred during the asynchronous operation.
Segment | The Segment object referencing the data that was sent or received.
State | Gets the object that was included as part of the associated method call.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace


SegmentEventArgs Class

Provides data for any event where data is sent or received.

For a list of all members of this type, see SegmentEventArgs Members.

System.Object
EventArgs
SegmentEventArgs

[Visual Basic]
Public Class SegmentEventArgs
Inherits EventArgs
[C#]
public class SegmentEventArgs : EventArgs

Remarks

A SegmentEventArgs object is passed as a parameter to all events that report the transfer of data. This object contains a Segment object that references the data sent/received.

If your code causes an exception, it would be returned to the handling event without you seeing it. To preclude such a condition, you should ALWAYS use a try/ catch block around your event-handling code.

Example

[Visual Basic, C#] The following example demonstrates asynchronous receiving and sending of data.

[Visual Basic]
Private Sub AsynchTcpDemo()

   ' Attempt to connect to an echo port.
   Try
      Tcp1.Connect("myserver", 7)
   Catch ex As Exception
      Return
   End Try

   ' Send data, since we are connected to an echo port, the same data should be returned.
   ' The following code demonstrates asynchronously sending data. When data has been sent
   ' the EndSend event will be raised.

   Dim buffer() As Byte = System.Text.Encoding.Default.GetBytes("a")
   Tcp1.BeginSend(buffer, 0, buffer.Length, Net.Sockets.SocketFlags.None, Nothing)
End Sub

Private Sub Tcp1_EndSend(ByVal sender As Object, ByVal e As Dart.PowerTCP.SegmentEventArgs) Handles Tcp1.EndSend
   ' Check for exception
   If e.Exception Is Nothing Then

      ' Send is complete. Display info about the data sent.
      Debug.WriteLine("Byte count sent: " + e.Segment.Count)
      Debug.WriteLine("Data sent: " + e.Segment.ToString())

      Dim buffer(Tcp1.ReceiveBufferSize) As Byte

      ' Receive the data. The EndReceive event will be raised upon completion.
      Tcp1.BeginReceive(buffer, 0, buffer.Length, Net.Sockets.SocketFlags.None, Nothing)

    End If
End Sub

Private Sub Tcp1_EndReceive(ByVal sender As Object, ByVal e As Dart.PowerTCP.SegmentEventArgs) Handles Tcp1.EndReceive
   ' Check for exception
   If e.Exception Is Nothing Then

      ' Receive is complete. Display info about the data sent.
      Debug.WriteLine("Byte count received: " + e.Segment.Count)
      Debug.WriteLine("Data received: " + e.Segment.ToString())

      ' Close the connection
      Tcp1.Close()
    End If
End Sub
[C#]
private void AsynchTcpDemo()
{
    // Attempt to connect to an echo port.
    try
    {
        tcp1.Connect("myserver", 7);
    }
    catch(Exception ex)
    {return;}

    // Send data, since we are connected to an echo port, the same data should be returned.
    // The following code demonstrates asynchronously sending data. When data has been sent
    // the EndSend event will be raised.

    byte[] buffer = System.Text.Encoding.Default.GetBytes("a");
    tcp1.BeginSend(buffer, 0, buffer.Length, System.Net.Sockets.SocketFlags.None, null);
}

private void tcp1_EndSend(object sender, Dart.PowerTCP.SegmentEventArgs e)
{
    // Check for exception
    if(e.Exception == null)
    {
        // Send is complete. Display info about the data sent.
        Debug.WriteLine("Byte count sent: " + e.Segment.Count);
        Debug.WriteLine("Data sent: " + e.Segment.ToString());

        byte[] buffer = new byte[tcp1.ReceiveBufferSize];

        // Receive the data. The EndReceive event will be raised upon completion.
        tcp1.BeginReceive(buffer, 0, buffer.Length, System.Net.Sockets.SocketFlags.None, null);
    }
}

private void tcp1_EndReceive(object sender, Dart.PowerTCP.SegmentEventArgs e)
{
    // Check for exception
    if(e.Exception == null)
    {
        // Receive is complete. Display info about the data sent.
        Debug.WriteLine("Byte count received: " + e.Segment.Count);
        Debug.WriteLine("Data received: " + e.Segment.ToString());

        // Close the connection
        tcp1.Close();
    }
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

SegmentEventArgs Members | Dart.PowerTCP.Telnet Namespace


SegmentEventArgs Members

SegmentEventArgs overview

Public Instance Properties

Exception | Gets any exception which occurred during the asynchronous operation.
Segment | The Segment object referencing the data that was sent or received.
State | Gets the object that was included as part of the associated method call.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

See Also

SegmentEventArgs Class | Dart.PowerTCP.Telnet Namespace


SegmentEventArgs Properties

The properties of the SegmentEventArgs class are listed below. For a complete list of SegmentEventArgs class members, see the SegmentEventArgs Members topic.

Public Instance Properties

Exception | Gets any exception which occurred during the asynchronous operation.
Segment | The Segment object referencing the data that was sent or received.
State | Gets the object that was included as part of the associated method call.

See Also

SegmentEventArgs Class | Dart.PowerTCP.Telnet Namespace


SegmentEventArgs.Exception Property

Gets any exception which occurred during the asynchronous operation.

[Visual Basic]
Public ReadOnly Property Exception As Exception
[C#]
public System.Exception Exception {get;}

Property Value

If any exception occurred during the asynchronous operation, this property will contain an Exception object describing the exception.

Remarks

Check this property to tell if an exception occurred during the asynchronous operation. If this property is null, no exception occurred.

The exception property is useful for checking exceptions and handling them appropriately. For example, if a bad command was sent to the server, a ProtocolException may be thrown. You could check this property to see if it was of type ProtocolException, than handle appropriately.

Example

[Visual Basic, C#] The following example demonstrates asynchronous receiving and sending of data.

[Visual Basic]
Private Sub AsynchTcpDemo()

   ' Attempt to connect to an echo port.
   Try
      Tcp1.Connect("myserver", 7)
   Catch ex As Exception
      Return
   End Try

   ' Send data, since we are connected to an echo port, the same data should be returned.
   ' The following code demonstrates asynchronously sending data. When data has been sent
   ' the EndSend event will be raised.

   Dim buffer() As Byte = System.Text.Encoding.Default.GetBytes("a")
   Tcp1.BeginSend(buffer, 0, buffer.Length, Net.Sockets.SocketFlags.None, Nothing)
End Sub

Private Sub Tcp1_EndSend(ByVal sender As Object, ByVal e As Dart.PowerTCP.SegmentEventArgs) Handles Tcp1.EndSend
   ' Check for exception
   If e.Exception Is Nothing Then

      ' Send is complete. Display info about the data sent.
      Debug.WriteLine("Byte count sent: " + e.Segment.Count)
      Debug.WriteLine("Data sent: " + e.Segment.ToString())

      Dim buffer(Tcp1.ReceiveBufferSize) As Byte

      ' Receive the data. The EndReceive event will be raised upon completion.
      Tcp1.BeginReceive(buffer, 0, buffer.Length, Net.Sockets.SocketFlags.None, Nothing)

    End If
End Sub

Private Sub Tcp1_EndReceive(ByVal sender As Object, ByVal e As Dart.PowerTCP.SegmentEventArgs) Handles Tcp1.EndReceive
   ' Check for exception
   If e.Exception Is Nothing Then

      ' Receive is complete. Display info about the data sent.
      Debug.WriteLine("Byte count received: " + e.Segment.Count)
      Debug.WriteLine("Data received: " + e.Segment.ToString())

      ' Close the connection
      Tcp1.Close()
    End If
End Sub
[C#]
private void AsynchTcpDemo()
{
    // Attempt to connect to an echo port.
    try
    {
        tcp1.Connect("myserver", 7);
    }
    catch(Exception ex)
    {return;}

    // Send data, since we are connected to an echo port, the same data should be returned.
    // The following code demonstrates asynchronously sending data. When data has been sent
    // the EndSend event will be raised.

    byte[] buffer = System.Text.Encoding.Default.GetBytes("a");
    tcp1.BeginSend(buffer, 0, buffer.Length, System.Net.Sockets.SocketFlags.None, null);
}

private void tcp1_EndSend(object sender, Dart.PowerTCP.SegmentEventArgs e)
{
    // Check for exception
    if(e.Exception == null)
    {
        // Send is complete. Display info about the data sent.
        Debug.WriteLine("Byte count sent: " + e.Segment.Count);
        Debug.WriteLine("Data sent: " + e.Segment.ToString());

        byte[] buffer = new byte[tcp1.ReceiveBufferSize];

        // Receive the data. The EndReceive event will be raised upon completion.
        tcp1.BeginReceive(buffer, 0, buffer.Length, System.Net.Sockets.SocketFlags.None, null);
    }
}

private void tcp1_EndReceive(object sender, Dart.PowerTCP.SegmentEventArgs e)
{
    // Check for exception
    if(e.Exception == null)
    {
        // Receive is complete. Display info about the data sent.
        Debug.WriteLine("Byte count received: " + e.Segment.Count);
        Debug.WriteLine("Data received: " + e.Segment.ToString());

        // Close the connection
        tcp1.Close();
    }
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

SegmentEventArgs Class | Dart.PowerTCP.Telnet Namespace


SegmentEventArgs.Segment Property

The Segment object referencing the data that was sent or received.

[Visual Basic]
Public ReadOnly Property Segment As Segment
[C#]
public Segment Segment {get;}

Property Value

A Segment object referencing the data that was sent or received.

Remarks

The Segment object will contain data describing the data that was sent or received. For example, the Segment object will contain the data itself, the amount of bytes sent,' and whether the Segment object was created as a result of data being sent or received.

To access the data contained within the Segment object, simply access the properties of the Segment object. As a shortcut, you can simply get all data contained within the Segment object by using the Segment.ToString method.

Example

[Visual Basic, C#] The following example demonstrates asynchronous receiving and sending of data.

[Visual Basic]
Private Sub AsynchTcpDemo()

   ' Attempt to connect to an echo port.
   Try
      Tcp1.Connect("myserver", 7)
   Catch ex As Exception
      Return
   End Try

   ' Send data, since we are connected to an echo port, the same data should be returned.
   ' The following code demonstrates asynchronously sending data. When data has been sent
   ' the EndSend event will be raised.

   Dim buffer() As Byte = System.Text.Encoding.Default.GetBytes("a")
   Tcp1.BeginSend(buffer, 0, buffer.Length, Net.Sockets.SocketFlags.None, Nothing)
End Sub

Private Sub Tcp1_EndSend(ByVal sender As Object, ByVal e As Dart.PowerTCP.SegmentEventArgs) Handles Tcp1.EndSend
   ' Check for exception
   If e.Exception Is Nothing Then

      ' Send is complete. Display info about the data sent.
      Debug.WriteLine("Byte count sent: " + e.Segment.Count)
      Debug.WriteLine("Data sent: " + e.Segment.ToString())

      Dim buffer(Tcp1.ReceiveBufferSize) As Byte

      ' Receive the data. The EndReceive event will be raised upon completion.
      Tcp1.BeginReceive(buffer, 0, buffer.Length, Net.Sockets.SocketFlags.None, Nothing)

    End If
End Sub

Private Sub Tcp1_EndReceive(ByVal sender As Object, ByVal e As Dart.PowerTCP.SegmentEventArgs) Handles Tcp1.EndReceive
   ' Check for exception
   If e.Exception Is Nothing Then

      ' Receive is complete. Display info about the data sent.
      Debug.WriteLine("Byte count received: " + e.Segment.Count)
      Debug.WriteLine("Data received: " + e.Segment.ToString())

      ' Close the connection
      Tcp1.Close()
    End If
End Sub
[C#]
private void AsynchTcpDemo()
{
    // Attempt to connect to an echo port.
    try
    {
        tcp1.Connect("myserver", 7);
    }
    catch(Exception ex)
    {return;}

    // Send data, since we are connected to an echo port, the same data should be returned.
    // The following code demonstrates asynchronously sending data. When data has been sent
    // the EndSend event will be raised.

    byte[] buffer = System.Text.Encoding.Default.GetBytes("a");
    tcp1.BeginSend(buffer, 0, buffer.Length, System.Net.Sockets.SocketFlags.None, null);
}

private void tcp1_EndSend(object sender, Dart.PowerTCP.SegmentEventArgs e)
{
    // Check for exception
    if(e.Exception == null)
    {
        // Send is complete. Display info about the data sent.
        Debug.WriteLine("Byte count sent: " + e.Segment.Count);
        Debug.WriteLine("Data sent: " + e.Segment.ToString());

        byte[] buffer = new byte[tcp1.ReceiveBufferSize];

        // Receive the data. The EndReceive event will be raised upon completion.
        tcp1.BeginReceive(buffer, 0, buffer.Length, System.Net.Sockets.SocketFlags.None, null);
    }
}

private void tcp1_EndReceive(object sender, Dart.PowerTCP.SegmentEventArgs e)
{
    // Check for exception
    if(e.Exception == null)
    {
        // Receive is complete. Display info about the data sent.
        Debug.WriteLine("Byte count received: " + e.Segment.Count);
        Debug.WriteLine("Data received: " + e.Segment.ToString());

        // Close the connection
        tcp1.Close();
    }
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

SegmentEventArgs Class | Dart.PowerTCP.Telnet Namespace


SegmentEventArgs.State Property

Gets the object that was included as part of the associated method call.

[Visual Basic]
Public ReadOnly Property State As Object
[C#]
public object State {get;}

Property Value

An object containing data passed into the calling asynchronous method.

Remarks

The EndEventArgs.State property can be used in the calling asynchronous method to make data accessable to the handling event.

This property is useful for making data accessible to the handling event. Since asynchronous methods are "disconnected" (meaning that when one is called, it executes on it's own and returns in the event handler) data that you were using in the code that called the asynchronous method may not be available in the event handler. Simply pass this data in as state when calling the asychronous method (usually a BeginXXX method) and it is available in the event handler. If you do not wish to make an object accessable in the EndXXX event, simple pass in null as state.

See Also

SegmentEventArgs Class | Dart.PowerTCP.Telnet Namespace


SegmentEventHandler Delegate

Represents the method (event handler) that is raised when data is received or sent.

[Visual Basic]
Public Delegate Sub SegmentEventHandler( _
ByVal sender As Object, _
ByVal e As SegmentEventArgs _
)
[C#]
public delegate void SegmentEventHandler(
object sender,
SegmentEventArgs e
);

Parameters

sender
The source of the event.
e
A SegmentEventArgs object that contains the event data.

Remarks

As Microsoft describes in their MSDN documentation, the event model in the .NET Framework is based on having an event delegate that connects an event with its handler. To raise an event, two elements are needed:

  • A class that holds the event data. This class must derive from the base class EventArgs.
  • A delegate that points to a method that provides the response to the event.
When sending or receiving data, the class that holds the event data is the SegmentEventArgs class. A method must be created with the same signature as the delegate. In this example that would mean a method would have to be defined to accept two arguments (an object and a SegmentEventArgs) and return void. Once this has been done, the delegate must be "connected" to the handling event. This is done by adding an instance of the delegate to the event.

For more information about event handler delegates, see the Using Events in PowerTCP topic.

If your code causes an exception, it would be returned to the handling event without you seeing it. To preclude such a condition, you should ALWAYS use a try/ catch block around your event-handling code.

Example

[Visual Basic, C#] The following example demonstrates using the Log event to create a text log of all data sent over the control connection.

[Visual Basic]
' The Trace Event will fire whenever data is sent/received over the control connection.
Private Sub Ftp1_Log(ByVal sender As Object, ByVal e As Dart.PowerTCP.Ftp.SegmentEventArgs) Handles Ftp1.Log
   ' Create FileStream to write to log file
   Dim stream1 As New System.IO.FileStream("c:\FtpTest\mylog.log", IO.FileMode.OpenOrCreate, IO.FileAccess.ReadWrite)

   ' Create text to precede sent/received data.
   Dim recv() As Byte = System.Text.Encoding.ASCII.GetBytes(vbCrLf + "Received <--" + vbCrLf)
   Dim sent() As Byte = System.Text.Encoding.ASCII.GetBytes(vbCrLf + "Sent -->" + vbCrLf)

   ' Set the stream position to append.
   stream1.Position = stream1.Length

   ' Check if data is incoming or outgoing and write appropriate data
   If e.Sent = True Then
      stream1.Write(sent, 0, sent.Length)
   Else
      stream1.Write(recv, 0, recv.Length)
   End If

   ' Write the data
   stream1.Write(e.Segment.Buffer, e.Segment.Offset, e.Segment.Count)

   ' Close the stream
   stream1.Close()

End Sub
[C#]
// The Trace Event will fire whenever data is sent/received.

private void Ftp1_Trace(object sender, Dart.PowerTCP.Ftp.SegmentEventArgs e)
{

    // Create FileStream to write to log file
    System.IO.FileStream stream1 = new System.IO.FileStream("c:\\FtpTest\\log.txt", System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite);

    // Create text to precede sent/received data.
    byte[] recv = System.Text.ASCIIEncoding.ASCII.GetBytes("\r\nReceived <-- \r\n");
    byte[] sent = System.Text.ASCIIEncoding.ASCII.GetBytes("\r\nSent --> \r\n");

    // Set the stream position to append.
    stream1.Position = stream1.Length;

    // Check if data is incoming or outgoing and write appropriate data
    if(e.Sent == true)
        stream1.Write(sent, 0, sent.Length);
    else
        stream1.Write(recv, 0, recv.Length);

    // Write the data
    stream1.Write(e.Segment.Buffer, e.Segment.Offset, e.Segment.Count);

    // Close the stream
    stream1.Close();

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

Dart.PowerTCP.Telnet Namespace


Tcp Class

The Tcp component provides comprehensive Transmission Control Protocol support.

For a list of all members of this type, see Tcp Members.

System.Object
MarshalByRefObject
Component
Tcp

[Visual Basic]
Public Class Tcp
Inherits Component
[C#]
public class Tcp : Component

Remarks

Use the Tcp Component to establish and manage socket-level streams of data. It simplifies the use of TCP communications by providing methods to establish connections, send and receive data, and terminate connections. Synchronous and asynchronous use is fully supported.

Using the Tcp Component

What follows are short usage descriptions. For more information, see the appropriate member topic.

Low-level interface vs stream interface: Choose between sending data directly over the socket using a low-level interface, or use the stream interface to send/receive data with additional, stream-specific functionality. If you wish to use the low-level interface, you would use the Tcp.Send and Tcp.Receive methods. If you wish to use the stream-interface, use the Tcp.Stream.Read and Tcp.Stream.Write methods.

Connecting: To connect to a host, use either Tcp.Connect (to connect synchronously) or Tcp.BeginConnect (to connect asynchronously), specifying a remote host and port to connect to. Both of these methods are overloaded to allow the specification of a local interface/port as well.

Sending data using the low-level interface: After connecting, send data by using either Tcp.Send (to send data synchronously) or Tcp.BeginSend (to send data asynchronously). These methods are overloaded to allow sending of strings or byte arrays. A Segment object is returned from all Send operations, containing information about the data sent.

Sending data using the stream interface: To send data using the stream interface, use Tcp.Stream.Write. The stream interface offers additional functionality over the low-level interface for sending data such as sending data up to a delimiter and sending data while replacing characters.

Receiving data using the low-level interface: To receive data, use either Tcp.Receive (to receive data synchronously) or Tcp.BeginReceive (to receive data asynchronously). This method is most useful when you either want to receive all available data in the buffer.

Receiving data using the stream-interface: To receive data using the stream interface, use Tcp.Stream.Read. The stream interface offers additional functionality over the low-level interface for receiving data such as receiving up to a delimiter or filling a fixed-size buffer.

Event notification: The Tcp component provides full event support including the Tcp.Trace event, raised when data is sent or received, the Tcp.ConnectedChanged event, raised when the value of Tcp.Connected changes.

Socket option configuration: The Tcp component enables socket option configuration (such as KeepAlive and NoDelay socket options, for example) by simply setting properties of the Tcp component. In addition, buffer-size/socket timeout configuration is possible by setting both the sending or receiving buffer size, and the sending and receiving timeout value.

Example

[Visual Basic, C#] The following example demonstrates connecting implementing the SMTP protocol using the Tcp component to send a simple message.

[Visual Basic]
Private Sub TcpDemo()

   ' The following code assumes that good responses are always received from
   ' the server. More robust code should check each response and handle appropriately.

   ' Connect to SMTP port
   Tcp1.Connect("mail", 25)

   ' Send the EHLO command
   Tcp1.Send("EHLO myserver" + vbCrLf)

   ' Get response from the server
   Dim seg As Segment = Tcp1.Receive()

   ' Send MAIL FROM command
   Tcp1.Send("MAIL FROM: test@myserver.com" + vbCrLf)

   ' Get response from the server
   seg = Tcp1.Receive()

   ' Send RCPT TO command
   Tcp1.Send("RCPT TO: you@yourserver.com" + vbCrLf)

   ' Get response from the server
   seg = Tcp1.Receive()

   ' Send DATA command
   Tcp1.Send("DATA" + vbCrLf)

   ' Get response from the server
   seg = Tcp1.Receive()

   ' Send DATA
   Tcp1.Send("Test Message" + vbCrLf + "." + vbCrLf)

   ' Receive response from the server
   seg = Tcp1.Receive()

   ' Write output
   Debug.WriteLine("Operation complete. The following information")
   Debug.WriteLine("was reported by the server:")
   Debug.WriteLine(seg.ToString())
End Sub
[C#]
private void TcpDemo()
{

   // The following code assumes that good responses are always received from
   // the server. More robust code should check each response and handle appropriately.

   // Connect to SMTP port
   tcp1.Connect("mail", 25);

   // Send the EHLO command
   tcp1.Send("EHLO myserver\r\n");

   // Get response from the server
   Segment seg = tcp1.Receive();

   // Send MAIL FROM command
   tcp1.Send("MAIL FROM: test@myserver.com\r\n");

   // Get response from the server
   seg = tcp1.Receive();

   // Send RCPT TO command
   tcp1.Send("RCPT TO: you@yourserver.com\r\n");

   // Get response from the server
   seg = tcp1.Receive();

   // Send DATA command
   tcp1.Send("DATA\r\n");

   // Get response from the server
   seg = tcp1.Receive();

   // Send DATA
   tcp1.Send("Test Message\r\n.\r\n");

   // Receive response from the server
   seg = tcp1.Receive();

   // Write output
   Debug.WriteLine("Operation complete. The following information");
   Debug.WriteLine("was reported by the server about the operation:");
   Debug.WriteLine(seg.ToString());
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

Tcp Members | Dart.PowerTCP.Telnet Namespace


Tcp Members

Tcp overview

Public Instance Constructors

Tcp Overloaded. Initializes a new instance of the Tcp class.

Public Instance Properties

AutoReceive | Gets or sets a value which determines if data is automatically receved.
Available | Gets the amount of data that has been received from the network and is available to be read.
Charset | Gets and sets the character set used for string/byte array conversions.
Connected | Gets the connected state of the connection.
ConnectTimeout | Gets or sets the number of milliseconds to wait for response from the server when connecting.
Container (inherited from Component) | Gets the IContainer that contains the Component.
DoEvents | Gets or sets a value that controls the processing of events during blocking method calls.
KeepAlive | Gets or sets the value of the socket's KeepAlive option.
LocalEndPoint | Returns the local address the socket is bound to.
NoDelay | Gets and sets a value the disables the use of Nagle's algorithm so that data is sent immediately.
OutOfBandInline | Gets or sets a value that indicates whether out-of-band (urgent) data is read as normal in-line data.
Proxy | Returns the Proxy instance that controls proxy server use.
ReceiveBufferSize | Gets and sets the size of the system receive buffer.
ReceiveTimeout | Gets and sets the number of milliseconds that a Tcp.Receive method will block before throwing a SocketException.
RemoteEndPoint | Returns the remote address/port the socket is connected to.
ReuseAddress | Gets or sets a value that typically allows any local port to be specified, even if it is already in use.
SendBufferSize | Gets and sets the size of the system send buffer.
SendTimeout | Gets and sets the number of milliseconds that a Tcp.Send method will block before throwing a SocketException.
Site (inherited from Component) | Gets or sets the ISite of the Component.
Socket | Returns a reference to the System.Net.Sockets.Socket instance being used.
Stream | Returns a SegmentedStream that can be used for advanced streaming operations on the socket.
SynchronizingObject | Set this object to automatically control thread marshalling between worker threads and the main UI thread.
Tag | Gets or sets an object reference that can be used to associate this instance with any other.

Public Instance Methods

BeginConnect | Overloaded. Connect to a server asynchronously, specifying the local interface and a range of local ports to use. The Tcp.EndConnect event is raised when completed.
BeginReceive | Overloaded. Receive data into your buffer asynchronously specifying a buffer, offset, size and SocketFlags value. The Tcp.EndReceive event is raised when completed.
BeginSend | Overloaded. Send data from your buffer asynchronously, specifying a buffer, offset, size and SocketFlags value. The Tcp.EndSend event is raised when completed.
Close | Overloaded. Close the connection.
Connect | Overloaded. Connect to a host, specifying the local interface and a range of local ports to use.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from Component) | Releases all resources used by the Component.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Receive | Overloaded. Receive data from the host, specifying a buffer, offset, size and SocketFlags value.
Send | Overloaded. Send data to the server, specifying a buffer, offset, size and SocketFlags value.
ToString (inherited from Component) |

Public Instance Events

ConnectedChanged | Raised when the value of the Object.Connected property changes.
Disposed (inherited from Component) | Adds an event handler to listen to the Disposed event on the component.
EndConnect | Raised when the Tcp.BeginConnect request completes.
EndReceive | Raised when the Tcp.BeginReceive request completes.
EndSend | Raised when the Tcp.BeginSend request completes.
RawTrace | Raised when data has been sent/received.
Trace | Raised when data has been sent/received.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp Constructor

Initializes a new instance of the Tcp class.

Overload List

Initializes a new instance of the Tcp class.

public Tcp();

Initializes a new instance of the Tcp class.

public Tcp(IContainer);

Initializes a new instance of the Tcp class, specifying the System.Net.Sockets.Socket to use for the underlying connection.

public Tcp(Socket);

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp Constructor (IContainer)

Initializes a new instance of the Tcp class.

[Visual Basic]
Overloads Public Sub New( _
ByVal container As IContainer _
)
[C#]
public Tcp(
IContainer container
);

Parameters

container
The IContainer which contains the object.

Remarks

Use this constructor to add the Tcp class to the IContainer container.

To create an instance of the Tcp component using Visual Studio.NET, simply add the Tcp component to the form and the object will automatically be created and initialized. If working out of the Visual Studio.NET environment (or using the Tcp component as a reference), the Tcp component will have to be explicitly created and initialized.

The following table shows initial property values for an instance of Tcp.

Property | Initial Value
Tcp.Available | 0
Tcp.Charset | Default system charset (accessible via System.Text.Encoding.Default.BodyName)
Tcp.Connected | false
Tcp.DoEvents | true
Tcp.KeepAlive | false
Tcp.LocalEndPoint | reference to System.Net.IPEndPoint
Tcp.NoDelay | false
Tcp.OutOfBandInline | false
Tcp.Proxy | reference to Dart.PowerTCP.Proxy
Tcp.ReceiveBufferSize | 8192
Tcp.ReceiveTimeout | 0
Tcp.RemoteEndPoint | reference to System.Net.IPEndPoint
Tcp.ReuseAddress | false
Tcp.SendBufferSize | 8192
Tcp.SendTimeout | 0
Tcp.Socket | null
Tcp.State | null
Tcp.Stream | SegmentedStream object

Example

[Visual Basic, C#] The following example demonstrates creating a Tcp object.

[Visual Basic]
' Declare as class member
Friend WithEvents Tcp1 As Dart.PowerTCP.SecureFtp.Tcp

' Create in class initialization
Me.Tcp1 = New Dart.PowerTCP.SecureFtp.Tcp()
[C#]
private Dart.PowerTCP.SecureFtp.Tcp tcp1 = new Dart.PowerTCP.SecureFtp.Tcp();

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace | Tcp Constructor Overload List


Tcp Constructor ()

Initializes a new instance of the Tcp class.

[Visual Basic]
Overloads Public Sub New()
[C#]
public Tcp();

Remarks

The default constructor initializes a new Tcp class.

To create an instance of the Tcp component using Visual Studio.NET, simply add the Tcp component to the form and the object will automatically be created and initialized. If working out of the Visual Studio.NET environment (or using the Tcp component as a reference), the Tcp component will have to be explicitly created and initialized.

The following table shows initial property values for an instance of Tcp.

Property | Initial Value
Tcp.Available | 0
Tcp.Charset | Default system charset (accessible via System.Text.Encoding.Default.BodyName)
Tcp.Connected | false
Tcp.DoEvents | true
Tcp.KeepAlive | false
Tcp.LocalEndPoint | reference to System.Net.IPEndPoint
Tcp.NoDelay | false
Tcp.OutOfBandInline | false
Tcp.Proxy | reference to Dart.PowerTCP.Proxy
Tcp.ReceiveBufferSize | 8192
Tcp.ReceiveTimeout | 0
Tcp.RemoteEndPoint | reference to System.Net.IPEndPoint
Tcp.ReuseAddress | false
Tcp.SendBufferSize | 8192
Tcp.SendTimeout | 0
Tcp.Socket | null
Tcp.State | null
Tcp.Stream | SegmentedStream object

Example

[Visual Basic, C#] The following example demonstrates creating a Tcp object.

[Visual Basic]
' Declare as class member
Friend WithEvents Tcp1 As Dart.PowerTCP.SecureFtp.Tcp

' Create in class initialization
Me.Tcp1 = New Dart.PowerTCP.SecureFtp.Tcp()
[C#]
private Dart.PowerTCP.SecureFtp.Tcp tcp1 = new Dart.PowerTCP.SecureFtp.Tcp();

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace | Tcp Constructor Overload List


Tcp Constructor (Socket)

Initializes a new instance of the Tcp class, specifying the System.Net.Sockets.Socket to use for the underlying connection.

[Visual Basic]
Overloads Public Sub New( _
ByVal acceptedSocket As Socket _
)
[C#]
public Tcp(
Socket acceptedSocket
);

Parameters

acceptedSocket
The System.Net.Sockets.Socket to use for the underlying connection.

Remarks

Use this constructor create an instance of the Tcp class using an already created Socket. Typically, this is used when a connection is made on a socket that is listening for connections.

To create an instance of the Tcp component using Visual Studio.NET, simply add the Tcp component to the form and the object will automatically be created and initialized. If working out of the Visual Studio.NET environment (or using the Tcp component as a reference), the Tcp component will have to be explicitly created and initialized.

The following table shows initial property values for an instance of Tcp.

Property | Initial Value
Tcp.Available | 0
Tcp.Charset | Default system charset (accessible via System.Text.Encoding.Default.BodyName)
Tcp.Connected | false
Tcp.DoEvents | true
Tcp.KeepAlive | false
Tcp.LocalEndPoint | reference to System.Net.IPEndPoint
Tcp.NoDelay | false
Tcp.OutOfBandInline | false
Tcp.Proxy | reference to Dart.PowerTCP.Proxy
Tcp.ReceiveBufferSize | 8192
Tcp.ReceiveTimeout | 0
Tcp.RemoteEndPoint | reference to System.Net.IPEndPoint
Tcp.ReuseAddress | false
Tcp.SendBufferSize | 8192
Tcp.SendTimeout | 0
Tcp.Socket | null
Tcp.State | null
Tcp.Stream | SegmentedStream object

Example

[Visual Basic, C#] The following example demonstrates creating a Tcp object.

[Visual Basic]
' Declare as class member
Friend WithEvents Tcp1 As Dart.PowerTCP.SecureFtp.Tcp

' Create in class initialization
Me.Tcp1 = New Dart.PowerTCP.SecureFtp.Tcp()
[C#]
private Dart.PowerTCP.SecureFtp.Tcp tcp1 = new Dart.PowerTCP.SecureFtp.Tcp();

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace | Tcp Constructor Overload List


Tcp Properties

The properties of the Tcp class are listed below. For a complete list of Tcp class members, see the Tcp Members topic.

Public Instance Properties

AutoReceive | Gets or sets a value which determines if data is automatically receved.
Available | Gets the amount of data that has been received from the network and is available to be read.
Charset | Gets and sets the character set used for string/byte array conversions.
Connected | Gets the connected state of the connection.
ConnectTimeout | Gets or sets the number of milliseconds to wait for response from the server when connecting.
Container (inherited from Component) | Gets the IContainer that contains the Component.
DoEvents | Gets or sets a value that controls the processing of events during blocking method calls.
KeepAlive | Gets or sets the value of the socket's KeepAlive option.
LocalEndPoint | Returns the local address the socket is bound to.
NoDelay | Gets and sets a value the disables the use of Nagle's algorithm so that data is sent immediately.
OutOfBandInline | Gets or sets a value that indicates whether out-of-band (urgent) data is read as normal in-line data.
Proxy | Returns the Proxy instance that controls proxy server use.
ReceiveBufferSize | Gets and sets the size of the system receive buffer.
ReceiveTimeout | Gets and sets the number of milliseconds that a Tcp.Receive method will block before throwing a SocketException.
RemoteEndPoint | Returns the remote address/port the socket is connected to.
ReuseAddress | Gets or sets a value that typically allows any local port to be specified, even if it is already in use.
SendBufferSize | Gets and sets the size of the system send buffer.
SendTimeout | Gets and sets the number of milliseconds that a Tcp.Send method will block before throwing a SocketException.
Site (inherited from Component) | Gets or sets the ISite of the Component.
Socket | Returns a reference to the System.Net.Sockets.Socket instance being used.
Stream | Returns a SegmentedStream that can be used for advanced streaming operations on the socket.
SynchronizingObject | Set this object to automatically control thread marshalling between worker threads and the main UI thread.
Tag | Gets or sets an object reference that can be used to associate this instance with any other.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.AutoReceive Property

Gets or sets a value which determines if data is automatically receved.

[Visual Basic]
Public Property AutoReceive As Boolean
[C#]
public bool AutoReceive {get; set;}

Property Value

true if data is to be automatically received; false otherwise. The default value is false.

Remarks

Setting this property to true will cause the component to automatically post a BeginReceive immediately after connecting. Once data is received, the Object.EndReceive event is raised. Upon exiting this event, a new Object.BeginReceive is posted. As a result,when you use this methodology, you simply need to connect to the server and send data. Data is automatically received and Object.EndReceive is raised with no explicit call to Object.BeginReceive required.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.Available Property

Gets the amount of data that has been received from the network and is available to be read.

[Visual Basic]
Public ReadOnly Property Available As Integer
[C#]
public int Available {get;}

Property Value

The number of bytes of data that has been received from the network and are available to be read.

Remarks

When data is received from the network, it is collected in system buffers. The Tcp.Available property contains the amount of bytes of data that has been received. In order to receive the data into a useful data structure such as a string, byte array, or Segment object that you can use within your application you must use the Tcp.Receive or Tcp.Stream.Read methods. If these methods are not invoked or are seldom invoked, then "back pressure" is exerted at the remote host and packet transmission rates will decrease. If these methods are invoked, the data is received and removed from the system buffers, making room for more data to be received from the network.

Example

[Visual Basic, C#] The following example demonstrates receiving a chunked response from the server. HTTP 1.1 allows a server to send a "chunked" response. When this occurs, the server will send the headers then a hex value representing the size of the next "chunk". This is continued until all data has been sent. This is a good stream example because it demonstrates both reading until a delimiter is found and reading fixed-size "chunks" of data.

[Visual Basic]
' Connect to HTTP Port
Tcp1.Connect("www.yahoo.com", 80)

' Send GET Request for home page. Be sure to specify HTTP/1.1 and Host
' to get a chunked response.
Dim command As Byte() = System.Text.Encoding.Default.GetBytes("GET / HTTP/1.1" + vbCrLf + "Host:www.yahoo.com" + vbCrLf + vbCrLf)
Tcp1.Stream.Write(command)

' Get the headers by reading until a double CRLF is found.
Dim found As Boolean = False
Dim s As String = Tcp1.Stream.Read(vbCrLf + vbCrLf, 1024, found)

Dim pagedata As String = ""

' Keep receiving data. When all data is sent, the server will close the connection.
Do While Tcp1.Connected

   ' Get the chunk size by reading until a CRLF is found.
   s = Tcp1.Stream.Read(vbCrLf, 1024, found)

   ' Remove the delimiter
   s = s.Trim()

   ' Make sure s has data
   If s <> "" Then

      ' Convert from string hex to decimal integer.
      Dim chunksize As Integer = System.Convert.ToInt32(s, 16)

      ' The final chunk will have size 0 and does not need to be handled.
      If chunksize <> 0 Then

         ' initialize byte array with chunk size
         Dim data(chunksize) As Byte

         ' Fill the byte array.
         Tcp1.Stream.Read(data, True)

         ' Add to the string
         pagedata += System.Text.Encoding.Default.GetString(data)
      End If
   End If
Loop

' Entire page should be retrieved by this point. Display
Debug.WriteLine(pagedata)
[C#]
// Connect to HTTP Port
tcp1.Connect("www.yahoo.com", 80);

// Send GET Request for home page. Be sure to specify HTTP/1.1 and Host
// to get a chunked response.
byte[] command  = System.Text.Encoding.Default.GetBytes("GET / HTTP/1.1\r\nHost:www.yahoo.com\r\n\r\n");
tcp1.Stream.Write(command);

// Get the headers by reading until a double CRLF is found.
bool found = false;
string s = tcp1.Stream.Read("\r\n\r\n", 1024, ref found);

string pagedata = "";

// Keep receiving data. When all data is sent, the server will close the connection.
while(tcp1.Connected)
{
   // Get the chunk size by reading until a CRLF is found.
   s = tcp1.Stream.Read("\r\n", 1024, ref found);

   // Remove the delimiter
   s = s.Trim();

   // Make sure s has data
   if(s != "")
   {
      // Convert from string hex to decimal integer.
      int chunksize = System.Convert.ToInt32(s, 16);

      // The final chunk will have size 0 and does not need to be handled.
      if(chunksize != 0)
      {
         // initialize byte array with chunk size
         byte[] data = new byte[chunksize];

         // Fill the byte array.
         tcp1.Stream.Read(data, true);

         // Add to the string
         pagedata+= System.Text.Encoding.Default.GetString(data);
      }
   }

}

// Entire page should be retrieved at this point. Display
Debug.WriteLine(pagedata);

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.Charset Property

Gets and sets the character set used for string/byte array conversions.

[Visual Basic]
Public Property Charset As String
[C#]
public string Charset {get; set;}

Property Value

A string representing the character set used.

Remarks

This value defaults to the language used on the runtime machine (accessable through System.Text.Encoding.Default.BodyName). Set this property to the desired character set string to override this behavior. An example charset for Kanji is "ISO-2022-JP", while standard ASCII is: "ISO-8859-1".

When communicating with clients from other countries set this property based on the standard string defined for the language intended. This enables the International client to be able to properly decode the data.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.Connected Property

Gets the connected state of the connection.

[Visual Basic]
Public ReadOnly Property Connected As Boolean
[C#]
public bool Connected {get;}

Property Value

true if the TCP connection is connected to a remote resource and authenticated; otherwise, false.

Remarks

If the PowerTCP component is connected to a remote resource AND authenticated, this property returns true. If this property is false, the connection was either never connected, is no longer connected, or is connected but not yet authenticated. When receiving data from the server, this property is a good way to tell if all data has been received. Keep receiving data in a loop until this property equals false.

When using PowerTCP components which make use of the Tcp component as the underlying connection, this property returns the same value as the Object.Connection.Connected property (where Object.Connection exposes the Tcp object used for the connection).

The Object.ConnectedChanged event is raised whenever this property changes.

Example

[Visual Basic, C#] The following example demonstrates the code required to build a simple echo server.

[Visual Basic]
Private Sub StartServer()
   ' Begin listening for connections on port 7.
   Server1.Listen(7)
End Sub

Private Sub Server1_Connection(ByVal sender As Object, ByVal e As Dart.PowerTCP.SecureFtp.ConnectionEventArgs) Handles Server1.Connection
   ' This event is raised on a new thread when a connection is received.
   Try
      ' Keep receiving data until connection is closed
      Do While (e.Tcp.Connected)
         ' Receive data.
         Dim seg As Dart.PowerTCP.SecureFtp.Segment = e.Tcp.Receive()

         ' Echo data back to client
         e.Tcp.Send(seg.ToString())
      Loop
   Catch ex As Exception
      'eat exception
   End Try
End Sub
[C#]
private void StartServer()
{
   // Begin listening for connections on port 7.
   server1.Listen(7);
}

private void server1_Connection(object sender, Dart.PowerTCP.SecureFtp.ConnectionEventArgs e)
{
   // This event is raised on a new thread when a connection is received.
   try
   {
      // Keep receiving data until connection is closed
      while(e.Tcp.Connected)
      {
         // Receive data.
         Dart.PowerTCP.SecureFtp.Segment seg = e.Tcp.Receive();

         // Echo data back to client.
         e.Tcp.Send(seg.ToString());
      }
   }
   catch(Exception ex)
   {
      // eat any exceptions
   }
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.ConnectTimeout Property

Gets or sets the number of milliseconds to wait for response from the server when connecting.

[Visual Basic]
Public Property ConnectTimeout As Integer
[C#]
public int ConnectTimeout {get; set;}

Property Value

The number of milliseconds to wait for response from the server when connecting. The default value is 0.

Remarks

The Object.Connect method will block for the amount of time specified by Object.ConnectTimeout. If no response is received from the server in this amount of time, a System.Net.SocketException will be thrown. The default value is 0, indicating no timeout is used.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.DoEvents Property

Gets or sets a value that controls the processing of events during blocking method calls.

[Visual Basic]
Public Property DoEvents As Boolean
[C#]
public bool DoEvents {get; set;}

Property Value

true if user-interface events should be processed during synchronous method calls; otherwise, false. The default value is true.

Remarks

When performing a synchronous (blocking) method, PowerTCP will process user-interface events (such as window painting) if this property is set to true AND the current thread has an event message queue. If no message queue is present (such as on an ASP page or under any worker thread), the value of this property has no effect. This property is used only for synchronous methods. Object.DoEvents is not needed if using asynchronous methods because the asynchronous method will execute on a different thread, allowing the UI thread to continue working unblocked.

For example, this property is beneficial when an interactive application is being used and the user may want to abort a currently processing operation by clicking an "Abort" button. If Object.DoEvents is set to false, this will not be possible. Set the Object.DoEvents property to true and the application will respond to other events (such as button clicks) during synchronous operations.

Example

[Visual Basic, C#] The following example demonstrates some of the lesser used Tcp component members.

[Visual Basic]
' Disable UI events.
Tcp1.DoEvents = False

' Enable KeepAlive socket option
Tcp1.KeepAlive = True

' Disable use of Nagle's Algoritm
Tcp1.NoDelay = True

' Read urgent data as normal in-line data.
Tcp1.OutOfBandInline = True

' Allow addresses to be reused
Tcp1.ReuseAddress = True

' Connect
Tcp1.Connect("atropos", 7)

' Send data
Tcp1.Send("test")

' Receive response
Dim seg As Segment = Tcp1.Receive()
[C#]
// Disable UI events.
tcp1.DoEvents = false;

// Enable KeepAlive socket option
tcp1.KeepAlive = true;

// Disable use of Nagle's Algoritm
tcp1.NoDelay = true;

// Read urgent data as normal in-line data.
tcp1.OutOfBandInline = true;

// Allow addresses to be reused
tcp1.ReuseAddress = true

// Connect
tcp1.Connect("atropos", 7);

// Send data
tcp1.Send("test");

// Receive response
Segment seg = tcp1.Receive();

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.KeepAlive Property

Gets or sets the value of the socket's KeepAlive option.

[Visual Basic]
Public Property KeepAlive As Boolean
[C#]
public bool KeepAlive {get; set;}

Property Value

true if packets are to be sent during inactive periods; otherwise, false. The default value is false.

Remarks

When a connection is inactive (data is not being sent or received for a period of time), setting Tcp.KeepAlive to true causes the underlying Socket of the Tcp component to probe the other end of a connection when it has been idle for an allotted amount of time (usually 2 hours).

This property can be used to ensure a connection reset indication occurs during periods of inactivity.

Example

[Visual Basic, C#] The following example demonstrates some of the lesser used Tcp component members.

[Visual Basic]
' Disable UI events.
Tcp1.DoEvents = False

' Enable KeepAlive socket option
Tcp1.KeepAlive = True

' Disable use of Nagle's Algoritm
Tcp1.NoDelay = True

' Read urgent data as normal in-line data.
Tcp1.OutOfBandInline = True

' Allow addresses to be reused
Tcp1.ReuseAddress = True

' Connect
Tcp1.Connect("atropos", 7)

' Send data
Tcp1.Send("test")

' Receive response
Dim seg As Segment = Tcp1.Receive()
[C#]
// Disable UI events.
tcp1.DoEvents = false;

// Enable KeepAlive socket option
tcp1.KeepAlive = true;

// Disable use of Nagle's Algoritm
tcp1.NoDelay = true;

// Read urgent data as normal in-line data.
tcp1.OutOfBandInline = true;

// Allow addresses to be reused
tcp1.ReuseAddress = true

// Connect
tcp1.Connect("atropos", 7);

// Send data
tcp1.Send("test");

// Receive response
Segment seg = tcp1.Receive();

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.LocalEndPoint Property

Returns the local address the socket is bound to.

[Visual Basic]
Public ReadOnly Property LocalEndPoint As IPEndPoint
[C#]
public System.Net.IPEndPoint LocalEndPoint {get;}

Property Value

The local IPEndPoint that the Tcp object is using for communications.

Remarks

null is returned when the Tcp.Connected property is false. When the Tcp.Connected property is true this property returns the IPEndPoint instance representing the local address and port. If a local interface was specified using the Tcp.Connect or Tcp.BeginConnect to connect to the host, this property should reflect that interface. Otherwise this property will reflect the default interface.

To retrieve the local IP address, access Tcp.LocalEndPoint.Address. To retrieve the local port, access Tcp.LocalEndPoint.Port. As a shortcut, use the Tcp.LocalEndPoint.ToString method to return the IP address and port in address:port notation.

Example

[Visual Basic, C#] The following example demonstrates using the ConnectedChanged event to notify the user of the status of the connection.

[Visual Basic]
Private Sub Tcp1_ConnectedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Tcp1.ConnectedChanged
   ' Get current state of connection
   If Tcp1.Connected Then
      Debug.WriteLine("Connection made")

      ' Display info about the local/remote endpoints
      Debug.WriteLine("Local endpoint: " + Tcp1.LocalEndPoint.ToString())
      Debug.WriteLine("Remote endpoint: " + Tcp1.RemoteEndPoint.ToString())
   Else
      Debug.WriteLine("Connection closed")
   End If
End Sub
[C#]
private void tcp1_ConnectedChanged(object sender, System.EventArgs e)
{
    // Get current state of connection
    if(tcp1.Connected)
    {
        Debug.WriteLine("Connection made");

        // Display info about the local/remote endpoints
        Debug.WriteLine("Local endpoint: " + tcp1.LocalEndPoint.ToString());
        Debug.WriteLine("Remote endpoint: " + tcp1.RemoteEndPoint.ToString());
    }
    else
        Debug.WriteLine("Connection closed");
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.NoDelay Property

Gets and sets a value the disables the use of Nagle's algorithm so that data is sent immediately.

[Visual Basic]
Public Property NoDelay As Boolean
[C#]
public bool NoDelay {get; set;}

Property Value

false if Nagle's algorithm is to be used; otherwise true. The default value is false.

Remarks

When small pieces of data (such as a byte) are send many times consecutively, inefficiency can result because a packet could be sent with 1 byte of useful data and 40 bytes of header information. Nagle's algorithm specifies that data such as this should be automatically concatenated and sent in a single packet. When true, Nagle's algorithm is defeated and data is immediately sent in a dedicated packet. When false, Nagle's algorithm is used so consecutive Send methods might send data as a single (more efficient) packet.

Setting this property to true could result in a speed optimization (because packets is sent immediately, without having to wait to see if Tcp.Send is called again). Setting this property to false results in data being transmitted more efficiently.

Example

[Visual Basic, C#] The following example demonstrates some of the lesser used Tcp component members.

[Visual Basic]
' Disable UI events.
Tcp1.DoEvents = False

' Enable KeepAlive socket option
Tcp1.KeepAlive = True

' Disable use of Nagle's Algoritm
Tcp1.NoDelay = True

' Read urgent data as normal in-line data.
Tcp1.OutOfBandInline = True

' Allow addresses to be reused
Tcp1.ReuseAddress = True

' Connect
Tcp1.Connect("atropos", 7)

' Send data
Tcp1.Send("test")

' Receive response
Dim seg As Segment = Tcp1.Receive()
[C#]
// Disable UI events.
tcp1.DoEvents = false;

// Enable KeepAlive socket option
tcp1.KeepAlive = true;

// Disable use of Nagle's Algoritm
tcp1.NoDelay = true;

// Read urgent data as normal in-line data.
tcp1.OutOfBandInline = true;

// Allow addresses to be reused
tcp1.ReuseAddress = true

// Connect
tcp1.Connect("atropos", 7);

// Send data
tcp1.Send("test");

// Receive response
Segment seg = tcp1.Receive();

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.OutOfBandInline Property

Gets or sets a value that indicates whether out-of-band (urgent) data is read as normal in-line data.

[Visual Basic]
Public Property OutOfBandInline As Boolean
[C#]
public bool OutOfBandInline {get; set;}

Property Value

true if urgent data is to be read as normal in-line data, otherwise false. The default value is false.

Remarks

When the "urgent" socket flag is set, this means that the packet contains data that should be acted upon before "non-urgent" data. Setting this property to true will cause this urgent data to be read in-line. If this property is set to false, the typical technique used to receive out-of-band data is BeginReceive(SocketFlags.Urgent) which posts a blocking receive on the socket waiting for urgent data to arrive.

To minimize interoperability problems, applications writers are advised not to use out-of-band data unless this is required in order to interoperate with an existing service.

Example

[Visual Basic, C#] The following example demonstrates some of the lesser used Tcp component members.

[Visual Basic]
' Disable UI events.
Tcp1.DoEvents = False

' Enable KeepAlive socket option
Tcp1.KeepAlive = True

' Disable use of Nagle's Algoritm
Tcp1.NoDelay = True

' Read urgent data as normal in-line data.
Tcp1.OutOfBandInline = True

' Allow addresses to be reused
Tcp1.ReuseAddress = True

' Connect
Tcp1.Connect("atropos", 7)

' Send data
Tcp1.Send("test")

' Receive response
Dim seg As Segment = Tcp1.Receive()
[C#]
// Disable UI events.
tcp1.DoEvents = false;

// Enable KeepAlive socket option
tcp1.KeepAlive = true;

// Disable use of Nagle's Algoritm
tcp1.NoDelay = true;

// Read urgent data as normal in-line data.
tcp1.OutOfBandInline = true;

// Allow addresses to be reused
tcp1.ReuseAddress = true

// Connect
tcp1.Connect("atropos", 7);

// Send data
tcp1.Send("test");

// Receive response
Segment seg = tcp1.Receive();

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.Proxy Property

Returns the Proxy instance that controls proxy server use.

[Visual Basic]
Public ReadOnly Property Proxy As Proxy
[C#]
public Proxy Proxy {get;}

Property Value

The Proxy object to use to control proxy server use.

Remarks

Some networks are configured to require your use of an TCP proxy server. PowerTCP supports most types. Configure your proxy use by specifying the properties of this Proxy object.

Use the Tcp.Proxy property if your application needs to connect with one of the following proxies:

  • SOCKS v4
  • SOCKS v5

Example

[Visual Basic, C#] The following example demonstrates asynchronously connecting using the BeginConnect method.

[Visual Basic]
Private Sub Test()
   ' Begin to asynchronously connect to an echo port.
   Tcp1.BeginConnect("atropos", 7)
End Sub

Private Sub Tcp1_EndConnect(ByVal sender As Object, ByVal e As Dart.PowerTCP.SecureFtp.ExceptionEventArgs) Handles Tcp1.EndConnect
   ' Connect complete, check for any exceptions
   If e.Exception Is Nothing Then
      ' Now send some data.
      Tcp1.Send("hello")

      ' Receive the data back.
      Dim seg As Segment = Tcp1.Receive()
      Debug.WriteLine(seg.ToString())
   End If
End Sub
[C#]
private void Test()
{
   // Begin to asynchronously connect to an echo port.
   tcp1.BeginConnect("atropos", 7);
}

private void tcp1_EndConnect(object sender, Dart.PowerTCP.SecureFtp.ExceptionEventArgs e)
{
   // Connect complete, check for any exceptions
   if(e.Exception == null)
   {
      // Now send some data.
      tcp1.Send("hello");

      // Receive the data back.
      Segment seg = tcp1.Receive();

      Debug.WriteLine(seg.ToString());
   }
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.ReceiveBufferSize Property

Gets and sets the size of the system receive buffer.

[Visual Basic]
Public Property ReceiveBufferSize As Integer
[C#]
public int ReceiveBufferSize {get; set;}

Property Value

Size of the system receive buffer in bytes. The default is 8192.

Remarks

This property sets the size of the system receive buffer. The default is 8192 which means that if the total data's bytes you are receiving exceeds this you will need to call Tcp.Receive multiple times until Tcp.Connection = false.

Example

[Visual Basic, C#] The following example demonstrates sending and receving data using byte arrays.

[Visual Basic]
' Connect to an echo port
Tcp1.Connect("atropos", 7)

' Send some bytes
Dim buffer As Byte() = System.Text.Encoding.Default.GetBytes("test")
Tcp1.Stream.Write(buffer, 0, buffer.Length)

' Receive the echoed data
Dim response(Tcp1.ReceiveBufferSize) As Byte
Tcp1.Stream.Read(response, 0, Tcp1.ReceiveBufferSize)

' Close the connection
Tcp1.Close()

' Display the response
Debug.WriteLine(System.Text.Encoding.Default.GetString(response))
[C#]
// Connect to an echo port
tcp1.Connect("atropos", 7);

// Send some bytes
byte[] buffer = System.Text.Encoding.Default.GetBytes("test");
tcp1.Stream.Write(buffer, 0, buffer.Length);

// Receive the echoed data
byte[] response = new byte[tcp1.ReceiveBufferSize];
tcp1.Stream.Read(response, 0, tcp1.ReceiveBufferSize);

// Close the connection
tcp1.Close();

// Display the response
Debug.WriteLine(System.Text.Encoding.Default.GetString(response));

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.ReceiveTimeout Property

Gets and sets the number of milliseconds that a Tcp.Receive method will block before throwing a SocketException.

[Visual Basic]
Public Property ReceiveTimeout As Integer
[C#]
public int ReceiveTimeout {get; set;}

Property Value

The timeout (in milliseconds) for completing a blocking Tcp.Receive or Tcp.Stream.Read.

Remarks

The Tcp component will block (not execute further code on the main thread) until either the data requested is received or until the method blocks for the time specified in Tcp.ReceiveTimeout, at which point a SocketException is thrown. The default is 0, which indicates no timeout. Setting this property has no effect on asynchronous methods such as Tcp.BeginRead.

This property is useful for determining network failure while receiving data. It is also useful for cases where the response from the server has to occur quickly or not at all, such as in an ASP script or when connecting and receiving data from a series of sockets in a batch process.

If building a server application, this value determines how long a child connection can be idle before disconnecting them.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.RemoteEndPoint Property

Returns the remote address/port the socket is connected to.

[Visual Basic]
Public ReadOnly Property RemoteEndPoint As IPEndPoint
[C#]
public System.Net.IPEndPoint RemoteEndPoint {get;}

Property Value

The remote IPEndPoint that the Tcp object is using for communications.

Remarks

null is returned when the Connected property is false. When the Tcp.Connected property is true this property returns the IPEndPoint instance representing the remote address and port.

To retrieve the remote IP address, access Tcp.RemoteEndPoint.Address. To retrieve the remote port, access Tcp.RemoteEndPoint.Port. As a shortcut, use the Tcp.RemoteEndPoint.ToString method to return the IP address and port in address:port notation.

Example

[Visual Basic, C#] The following example demonstrates using the ConnectedChanged event to notify the user of the status of the connection.

[Visual Basic]
Private Sub Tcp1_ConnectedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Tcp1.ConnectedChanged
   ' Get current state of connection
   If Tcp1.Connected Then
      Debug.WriteLine("Connection made")

      ' Display info about the local/remote endpoints
      Debug.WriteLine("Local endpoint: " + Tcp1.LocalEndPoint.ToString())
      Debug.WriteLine("Remote endpoint: " + Tcp1.RemoteEndPoint.ToString())
   Else
      Debug.WriteLine("Connection closed")
   End If
End Sub
[C#]
private void tcp1_ConnectedChanged(object sender, System.EventArgs e)
{
    // Get current state of connection
    if(tcp1.Connected)
    {
        Debug.WriteLine("Connection made");

        // Display info about the local/remote endpoints
        Debug.WriteLine("Local endpoint: " + tcp1.LocalEndPoint.ToString());
        Debug.WriteLine("Remote endpoint: " + tcp1.RemoteEndPoint.ToString());
    }
    else
        Debug.WriteLine("Connection closed");
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.ReuseAddress Property

Gets or sets a value that typically allows any local port to be specified, even if it is already in use.

[Visual Basic]
Public Property ReuseAddress As Boolean
[C#]
public bool ReuseAddress {get; set;}

Property Value

true if a specific local port number is desired for multiple active connections; otherwise false. The default is false, to indicate it should not be allowed.

Remarks

The option is used (set to true) when a specific local port number is desired for multiple active connections.

Example

[Visual Basic, C#] The following example demonstrates some of the lesser used Tcp component members.

[Visual Basic]
' Disable UI events.
Tcp1.DoEvents = False

' Enable KeepAlive socket option
Tcp1.KeepAlive = True

' Disable use of Nagle's Algoritm
Tcp1.NoDelay = True

' Read urgent data as normal in-line data.
Tcp1.OutOfBandInline = True

' Allow addresses to be reused
Tcp1.ReuseAddress = True

' Connect
Tcp1.Connect("atropos", 7)

' Send data
Tcp1.Send("test")

' Receive response
Dim seg As Segment = Tcp1.Receive()
[C#]
// Disable UI events.
tcp1.DoEvents = false;

// Enable KeepAlive socket option
tcp1.KeepAlive = true;

// Disable use of Nagle's Algoritm
tcp1.NoDelay = true;

// Read urgent data as normal in-line data.
tcp1.OutOfBandInline = true;

// Allow addresses to be reused
tcp1.ReuseAddress = true

// Connect
tcp1.Connect("atropos", 7);

// Send data
tcp1.Send("test");

// Receive response
Segment seg = tcp1.Receive();

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.SendBufferSize Property

Gets and sets the size of the system send buffer.

[Visual Basic]
Public Property SendBufferSize As Integer
[C#]
public int SendBufferSize {get; set;}

Property Value

The size of the system send buffer in bytes. The default is 8192.

Remarks

This property sets the size of the system send buffer. The default is 8192 which means that if the total data's bytes you are sending exceeds this you will need to call Tcp.Send multiple times.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.SendTimeout Property

Gets and sets the number of milliseconds that a Tcp.Send method will block before throwing a SocketException.

[Visual Basic]
Public Property SendTimeout As Integer
[C#]
public int SendTimeout {get; set;}

Property Value

The timeout (in milli-seconds) for completing a blocking Tcp.Send or SegmentedStream.Write. The default is 0, which indicates no timeout.

Remarks

The Tcp component will block (not execute further code on the main thread) until either the data is sent or until the method blocks for the time specified in Tcp.SendTimeout, at which point a SocketException is thrown. The default is 0, which indicates no timeout. Setting this property has no effect on asynchronous methods such as Tcp.BeginSend.

This property is useful for determining network failure while sending data. It is also useful for cases where sending data has to occur quickly or not at all, such as in an ASP script or when connecting and sending data to a series of sockets in a batch process.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.Socket Property

Returns a reference to the System.Net.Sockets.Socket instance being used.

[Visual Basic]
Public ReadOnly Property Socket As Socket
[C#]
public System.Net.Sockets.Socket Socket {get;}

Property Value

The System.Net.Sockets.Socket being used for the TCP connection.

Remarks

The Socket used for the TCP connection is exposed through this property. It is not recommended to read or write to the TCP stream using the Socket object directly. To read or write, use the higher-level methods such as Tcp.Receive or Tcp.Send, or members of Tcp.Stream such as Tcp.Stream.Read and Tcp.Stream.Write.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.Stream Property

Returns a SegmentedStream that can be used for advanced streaming operations on the socket.

[Visual Basic]
Public Property Stream As SegmentedStream
[C#]
public SegmentedStream Stream {get; set;}

Property Value

A SegmentedStream object.

Remarks

Typically, when data needs to be send or received, the Object.Send or Object.Receive methods can be used. However, often advanced streaming operations are required. Two of the most common are reading token-delimited segments and fixed-length segments. To read fixed-length segments, simply create a fixed-size byte array the size of the segment you would like to read. Then use the Object.Stream.Read method, passing in the byte array and true as the fill parameter. Data is read until either all available data has been received, or the array has been completely filled with data. To read token-delimited segments, create an array of characters that you would like to use as a delimiter. Then use the Object.Stream.Read, passing in the delimiter array. Data is read until the delimiter has been reached. If the delimiter is not found, data is read until all data has been received.

Note: The following applies to using the Tcp.Stream property with secure PowerTCP implementations only! In addition, you can change the initialization of this property to change the behavior of the way data is read or written. Since SegmentedStream is a PipeStream type, Object.Stream.CoreStream can be changed to any type of PipeStream. The PowerTCP secure implementation works this way. For example, if you wish to change to secure communications using SSL, you would initlialize the Object.Stream property using an SslStream like so,

// Initialize the Stream property to a new PipeStream "combination", enabling SSL communication.
// (This only applies to using the Tcp component to communicate securely.)
tcp1.Stream = new SegmentedStream(new SslStream(new TcpStream(tcp1)));

And, to switch back to "normal" communications,

// Switch back to a non-secure PipeStream "combination.
tcp1.Stream = new SegmentedStream(new TcpStream(tcp1));

Note for Tcp component usage only:Internally, the Tcp component will "scan" this property to link in the Tcp.CertificateReceivedEvent and Tcp.CertificateRequestedEvent, so these events do not need to be explicitly linked in unless you require advanced functionality.

Example

[Visual Basic, C#] The following example demonstrates connecting implementing the SMTP protocol using the Tcp component's stream interface to send a simple message.

[Visual Basic]
' The following code assumes that good responses are always received from
' the server. More robust code should check each response and handle appropriately.

' Connect to SMTP port
Tcp1.Connect("mail", 25)

' Send the EHLO command
Tcp1.Stream.Write("EHLO myserver\r\n")

' Get response from the server
Dim s As String = Tcp1.Stream.Read()

' Send MAIL FROM command
Tcp1.Stream.Write("MAIL FROM: test@dart.com" + vbCrLf)

' Get response from the server
s = Tcp1.Stream.Read()

' Send RCPT TO command
Tcp1.Stream.Write("RCPT TO: cranford@dart.com" + vbCrLf)

' Get response from the server
s = Tcp1.Stream.Read()

' Send DATA command
Tcp1.Stream.Write("DATA" + vbCrLf)

' Get response from the server
s = Tcp1.Stream.Read()

' Send DATA
Tcp1.Stream.Write("Test Message" + vbCrLf + "." + vbCrLf)

' Receive response from the server
s = Tcp1.Stream.Read()

' Write output
Debug.WriteLine("Operation complete. The following information")
Debug.WriteLine("was reported by the server:")
Debug.WriteLine(s)
[C#]
// The following code assumes that good responses are always received from
// the server. More robust code should check each response and handle appropriately.

// Connect to SMTP port
tcp1.Connect("mail", 25);

// Send the EHLO command
tcp1.Stream.Write("EHLO myserver\r\n");

// Get response from the server
string s = tcp1.Stream.Read();

// Send MAIL FROM command
tcp1.Stream.Write("MAIL FROM: test@dart.com\r\n");

// Get response from the server
s = tcp1.Stream.Read();

// Send RCPT TO command
tcp1.Stream.Write("RCPT TO: cranford@dart.com\r\n");

// Get response from the server
s = tcp1.Stream.Read();

// Send DATA command
tcp1.Stream.Write("DATA\r\n");

// Get response from the server
s = tcp1.Stream.Read();

// Send DATA
tcp1.Stream.Write("Test Message\r\n.\r\n");

// Receive response from the server
s = tcp1.Stream.Read();

// Write output
Debug.WriteLine("Operation complete. The following information");
Debug.WriteLine("was reported by the server:");
Debug.WriteLine(s);

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.Tag Property

Gets or sets an object reference that can be used to associate this instance with any other.

[Visual Basic]
Public Property Tag As Object
[C#]
public object Tag {get; set;}

Property Value

Any object that is associated with the component; null if no objects are associated with the component. Any object that is associated with the object, null if no objects are associated with the object

Remarks

Use this property to associate any type derived from Object class with the component. A common use for the Tag property is to store data that is closely associated with the component.

Use this property to associate any object with the object.

Example

[Visual Basic, C#] The following example demonstrates a simple multi-client chat server.

[Visual Basic]
Private Sub StartServer()
   ' Begin listening for connections on port 8888.
   Server1.Listen(8888)
End Sub

Private Sub Server1_Connection(ByVal sender As Object, ByVal e As Dart.PowerTCP.SecureFtp.ConnectionEventArgs) Handles Server1.Connection
   ' This event is raised on a new thread when a connection is received.
   Try
      ' Send username command.
      e.Tcp.Stream.Write("Please enter your username: ")

      ' Read until a CRLF is reached
      Dim found As Boolean = False
      Dim s As String = e.Tcp.Stream.Read(vbCrLf, 1024, found)

      If (found) Then
         ' Trim(whitespace)
         s = s.Trim()

         ' Associate username with TCP instance
         e.Tcp.Tag = s
         e.Tcp.Stream.Write("Go ahead and chat" + vbCrLf)
      Else
         ' Disconnect
         e.Tcp.Stream.Write("Bad Input" + vbCrLf)
         e.Tcp.Stream.Close()
      End If

      Do While (e.Tcp.Connected)

         ' Receive data.
         found = False
         Dim text As String = e.Tcp.Stream.Read(vbCrLf, 1024, found)

         ' Echo data back to all clients
         Dim tcp As Dart.PowerTCP.SecureFtp.Tcp
         For Each tcp In Server1.Connections
            ' Preface text with user name and send
            tcp.Stream.Write(e.Tcp.Tag.ToString() + ": " + text + vbCrLf)
         Next
      Loop
   Catch ex As Exception
      ' eat exception
   End Try
End Sub
[C#]
private void StartServer()
{
   // Begin listening for connections on port 8888.
   server1.Listen(8888);
}

private void server1_Connection(object sender, Dart.PowerTCP.SecureFtp.ConnectionEventArgs e)
{
   // This event is raised on a new thread when a connection is received.
   try
   {
      // Send username command.
      e.Tcp.Stream.Write("Please enter your username: ");

      // Read until a CRLF is reached
      bool found = false;
      string s = e.Tcp.Stream.Read("\r\n", 1024, ref found);

      if(found)
      {
         // Trim whitespace
         s = s.Trim();

         // Associate username with TCP instance
         e.Tcp.Tag = s;
         e.Tcp.Stream.Write("Go ahead and chat\r\n");
      }
      else
      {
         // Disconnect
         e.Tcp.Stream.Write("Bad Input\r\n");
         e.Tcp.Stream.Close();
      }
      while(e.Tcp.Connected)
      {
         // Receive data.
         found = false;
         string text = e.Tcp.Stream.Read("\r\n", 1024, ref found);

         // Echo data back to all clients
         foreach(Dart.PowerTCP.SecureFtp.Tcp tcp in server1.Connections)
         {
            // Preface text with user name (from Tcp.Tag) and send
            tcp.Stream.Write(e.Tcp.Tag.ToString() + ": " + text + "\r\n");
         }
      }
   }
   catch(Exception ex)
   {
      // eat exception
   }
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp Methods

The methods of the Tcp class are listed below. For a complete list of Tcp class members, see the Tcp Members topic.

Public Instance Methods

BeginConnect | Overloaded. Connect to a server asynchronously, specifying the local interface and a range of local ports to use. The Tcp.EndConnect event is raised when completed.
BeginReceive | Overloaded. Receive data into your buffer asynchronously specifying a buffer, offset, size and SocketFlags value. The Tcp.EndReceive event is raised when completed.
BeginSend | Overloaded. Send data from your buffer asynchronously, specifying a buffer, offset, size and SocketFlags value. The Tcp.EndSend event is raised when completed.
Close | Overloaded. Close the connection.
Connect | Overloaded. Connect to a host, specifying the local interface and a range of local ports to use.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from Component) | Releases all resources used by the Component.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Receive | Overloaded. Receive data from the host, specifying a buffer, offset, size and SocketFlags value.
Send | Overloaded. Send data to the server, specifying a buffer, offset, size and SocketFlags value.
ToString (inherited from Component) |

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


BeginConnect Method

PowerTCP Telnet for .NET

Tcp.BeginConnect Method

Connect to a server asynchronously. The Tcp.EndConnect event is raised when completed.

Overload List

Connect to a server asynchronously. The Tcp.EndConnect event is raised when completed.

public IAsyncResult BeginConnect(string,int);

Connect to a server asynchronously, specifying the local interface and a range of local ports to use. The Tcp.EndConnect event is raised when completed.

public virtual IAsyncResult BeginConnect(string,int,string,int,int,object);

Connect to a server asynchronously, specifying the local interface to use. The Tcp.EndConnect event is raised when completed.

public IAsyncResult BeginConnect(string,int,string,int,object);

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.BeginConnect Method (String, Int32)

Connect to a server asynchronously. The Tcp.EndConnect event is raised when completed.

[Visual Basic]
Overloads Public Function BeginConnect( _
ByVal server As String, _
ByVal serverPort As Integer _
) As IAsyncResult
[C#]
public IAsyncResult BeginConnect(
string server,
int serverPort
);

Parameters

server
Remote hostname or address in dot notation.
serverPort
Remote port, a number between 1 and 65535, inclusive.

Return Value

An IAsyncResult that represents the asynchronous operation, which could still be pending.

Remarks

Use this method if you wish to connect to a host transparently with minimal application impact, as execution occurs on another thread. This method begins to asynchronously connect to the server. Upon completion (on both success and failure) the Tcp.EndConnect event is raised. An EventArgs object is passed into this event, containing information about the event. If the connection succeeds, the ConnectedChanged event is raised. Once the connection has been made, you can send and receive data from the remote device.

If you are using the Tcp component as a reference, you must "wire up" the event yourself. This involves creating a method as the event handler that implements the EventHandler delegate.

For more information on implementing and handling events using PowerTCP.NET, see the topic, Using Events In PowerTCP.

To connect synchronously, use the Tcp.Connect method.

Exceptions

Exception Type | Condition
InvalidOperationException | BeginXXX method used without providing an EndXXX event handler.

Example

[Visual Basic, C#] The following example demonstrates asynchronously connecting using the BeginConnect method.

[Visual Basic]
Private Sub Test()
   ' Begin to asynchronously connect to an echo port.
   Tcp1.BeginConnect("atropos", 7)
End Sub

Private Sub Tcp1_EndConnect(ByVal sender As Object, ByVal e As Dart.PowerTCP.SecureFtp.ExceptionEventArgs) Handles Tcp1.EndConnect
   ' Connect complete, check for any exceptions
   If e.Exception Is Nothing Then
      ' Now send some data.
      Tcp1.Send("hello")

      ' Receive the data back.
      Dim seg As Segment = Tcp1.Receive()
      Debug.WriteLine(seg.ToString())
   End If
End Sub
[C#]
private void Test()
{
   // Begin to asynchronously connect to an echo port.
   tcp1.BeginConnect("atropos", 7);
}

private void tcp1_EndConnect(object sender, Dart.PowerTCP.SecureFtp.ExceptionEventArgs e)
{
   // Connect complete, check for any exceptions
   if(e.Exception == null)
   {
      // Now send some data.
      tcp1.Send("hello");

      // Receive the data back.
      Segment seg = tcp1.Receive();

      Debug.WriteLine(seg.ToString());
   }
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace | Tcp.BeginConnect Overload List


Tcp.BeginConnect Method (String, Int32, String, Int32, Int32, Object)

Connect to a server asynchronously, specifying the local interface and a range of local ports to use. The Tcp.EndConnect event is raised when completed.

[Visual Basic]
Overridable Overloads Public Function BeginConnect( _
ByVal server As String, _
ByVal serverPort As Integer, _
ByVal client As String, _
ByVal clientPortMin As Integer, _
ByVal clientPortMax As Integer, _
ByVal state As Object _
) As IAsyncResult
[C#]
public virtual IAsyncResult BeginConnect(
string server,
int serverPort,
string client,
int clientPortMin,
int clientPortMax,
object state
);

Parameters

server
Remote hostname or address in dot notation.
serverPort
Remote port, a number between 1 and 65535, inclusive.
client
Optional local hostname or address in dot notation. Use "" as default.
clientPortMin
The minimum client port number to use as a local interface.
clientPortMax
The maximim client port number to use as a local interface.
state
User state information.

Return Value

An IAsyncResult that represents the asynchronous operation, which could still be pending.

Remarks

Use this method if you wish to connect to a host transparently with minimal application impact, as execution occurs on another thread. This method begins to asynchronously connect to the server. Upon completion (on both success and failure) the Tcp.EndConnect event is raised. An EventArgs object is passed into this event, containing information about the event. If the connection succeeds, the ConnectedChanged event is raised. Once the connection has been made, you can send and receive data from the remote device.

If you are using the Tcp component as a reference, you must "wire up" the event yourself. This involves creating a method as the event handler that implements the EventHandler delegate.

For more information on implementing and handling events using PowerTCP.NET, see the topic, Using Events In PowerTCP.

To connect synchronously, use the Tcp.Connect method.

Exceptions

Exception Type | Condition
InvalidOperationException | BeginXXX method used without providing an EndXXX event handler.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace | Tcp.BeginConnect Overload List


Tcp.BeginConnect Method (String, Int32, String, Int32, Object)

Connect to a server asynchronously, specifying the local interface to use. The Tcp.EndConnect event is raised when completed.

[Visual Basic]
Overloads Public Function BeginConnect( _
ByVal server As String, _
ByVal serverPort As Integer, _
ByVal client As String, _
ByVal clientPort As Integer, _
ByVal state As Object _
) As IAsyncResult
[C#]
public IAsyncResult BeginConnect(
string server,
int serverPort,
string client,
int clientPort,
object state
);

Parameters

server
Remote hostname or address in dot notation.
serverPort
Remote port, a number between 1 and 65535, inclusive.
client
Optional local hostname or address in dot notation. Use "" as default.
clientPort
Optional local port, a number between 1 and 65535, inclusive. Use 0 as default.
state
User state information.

Return Value

An IAsyncResult that represents the asynchronous operation, which could still be pending.

Remarks

Use this method if you wish to connect to a host transparently with minimal application impact, as execution occurs on another thread. This method begins to asynchronously connect to the server. Upon completion (on both success and failure) the Tcp.EndConnect event is raised. An EventArgs object is passed into this event, containing information about the event. If the connection succeeds, the ConnectedChanged event is raised. Once the connection has been made, you can send and receive data from the remote device.

If you are using the Tcp component as a reference, you must "wire up" the event yourself. This involves creating a method as the event handler that implements the EventHandler delegate.

For more information on implementing and handling events using PowerTCP.NET, see the topic, Using Events In PowerTCP.

To connect synchronously, use the Tcp.Connect method.

Exceptions

Exception Type | Condition
InvalidOperationException | BeginXXX method used without providing an EndXXX event handler.

Example

[Visual Basic, C#] The following example demonstrates asynchronously connecting using the BeginConnect method.

[Visual Basic]
Private Sub Test()
   ' Begin to asynchronously connect to an echo port.
   Tcp1.BeginConnect("atropos", 7)
End Sub

Private Sub Tcp1_EndConnect(ByVal sender As Object, ByVal e As Dart.PowerTCP.SecureFtp.ExceptionEventArgs) Handles Tcp1.EndConnect
   ' Connect complete, check for any exceptions
   If e.Exception Is Nothing Then
      ' Now send some data.
      Tcp1.Send("hello")

      ' Receive the data back.
      Dim seg As Segment = Tcp1.Receive()
      Debug.WriteLine(seg.ToString())
   End If
End Sub
[C#]
private void Test()
{
   // Begin to asynchronously connect to an echo port.
   tcp1.BeginConnect("atropos", 7);
}

private void tcp1_EndConnect(object sender, Dart.PowerTCP.SecureFtp.ExceptionEventArgs e)
{
   // Connect complete, check for any exceptions
   if(e.Exception == null)
   {
      // Now send some data.
      tcp1.Send("hello");

      // Receive the data back.
      Segment seg = tcp1.Receive();

      Debug.WriteLine(seg.ToString());
   }
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace | Tcp.BeginConnect Overload List


BeginReceive Method

PowerTCP Telnet for .NET

Tcp.BeginReceive Method

Receive data into your buffer asynchronously. The Tcp.EndReceive event is raised when completed.

Overload List

Receive data into your buffer asynchronously. The Tcp.EndReceive event is raised when completed.

public IAsyncResult BeginReceive(byte[]);

Receive data into your buffer asynchronously specifying a buffer, offset, size and SocketFlags value. The Tcp.EndReceive event is raised when completed.

public IAsyncResult BeginReceive(byte[],int,int,SocketFlags,object);

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.BeginReceive Method (Byte[])

Receive data into your buffer asynchronously. The Tcp.EndReceive event is raised when completed.

[Visual Basic]
Overloads Public Function BeginReceive( _
ByVal buffer As Byte() _
) As IAsyncResult
[C#]
public IAsyncResult BeginReceive(
byte[] buffer
);

Parameters

buffer
Destination memory location to store received data.

Return Value

An IAsyncResult that represents the asynchronous operation, which could still be pending.

Remarks

The Tcp.BeginReceive method is used to receive data into a buffer asynchronously. When data has been received, the Tcp.EndReceive event is raised. A SegmentEventArgs object is passed into this event, containing a Segment object which encaspsulates information about the data itself and the amount of bytes of data received.

The object state is useful for any kind of state information you would like accessible in the Tcp.EndReceive event. Since the method is "disconnected" from the calling code and returns to the calling thread elsewhere, you may wish to pass an object/variable as state to be retrieved and used in the event handler.

If you are using the Tcp component as a reference, you must "wire up" the event yourself. This involves creating a method as the event handler that implements the SegmentEventHandler delegate.

To synchronously receive data, use the Tcp.Receive method.

Use this method if you wish to receive data into a buffer transparently with minimal application impact, as execution occurs on another thread. This method is the standard means for asynchronously receiving data. All available data is received.

Exceptions

Exception Type | Condition
InvalidOperationException | BeginXXX method used without providing an EndXXX event handler.
IOException | The stream is not Readable.
ArgumentNullException | buffer is null.
ArgumentOutOfRangeException | offset or size is less than 0.
ArgumentException | offset + size is greater than the length of buffer.
SocketException | The socket is not connected.

Example

[Visual Basic, C#] The following example demonstrates asynchronous receiving and sending of data.

[Visual Basic]
Private Sub AsynchTcpDemo()

   ' Attempt to connect to an echo port.
   Try
      Tcp1.Connect("myserver", 7)
   Catch ex As Exception
      Return
   End Try

   ' Send data, since we are connected to an echo port, the same data should be returned.
   ' The following code demonstrates asynchronously sending data. When data has been sent
   ' the EndSend event will be raised.

   Dim buffer() As Byte = System.Text.Encoding.Default.GetBytes("a")
   Tcp1.BeginSend(buffer, 0, buffer.Length, Net.Sockets.SocketFlags.None, Nothing)
End Sub

Private Sub Tcp1_EndSend(ByVal sender As Object, ByVal e As Dart.PowerTCP.SegmentEventArgs) Handles Tcp1.EndSend
   ' Check for exception
   If e.Exception Is Nothing Then

      ' Send is complete. Display info about the data sent.
      Debug.WriteLine("Byte count sent: " + e.Segment.Count)
      Debug.WriteLine("Data sent: " + e.Segment.ToString())

      Dim buffer(Tcp1.ReceiveBufferSize) As Byte

      ' Receive the data. The EndReceive event will be raised upon completion.
      Tcp1.BeginReceive(buffer, 0, buffer.Length, Net.Sockets.SocketFlags.None, Nothing)

    End If
End Sub

Private Sub Tcp1_EndReceive(ByVal sender As Object, ByVal e As Dart.PowerTCP.SegmentEventArgs) Handles Tcp1.EndReceive
   ' Check for exception
   If e.Exception Is Nothing Then

      ' Receive is complete. Display info about the data sent.
      Debug.WriteLine("Byte count received: " + e.Segment.Count)
      Debug.WriteLine("Data received: " + e.Segment.ToString())

      ' Close the connection
      Tcp1.Close()
    End If
End Sub
[C#]
private void AsynchTcpDemo()
{
    // Attempt to connect to an echo port.
    try
    {
        tcp1.Connect("myserver", 7);
    }
    catch(Exception ex)
    {return;}

    // Send data, since we are connected to an echo port, the same data should be returned.
    // The following code demonstrates asynchronously sending data. When data has been sent
    // the EndSend event will be raised.

    byte[] buffer = System.Text.Encoding.Default.GetBytes("a");
    tcp1.BeginSend(buffer, 0, buffer.Length, System.Net.Sockets.SocketFlags.None, null);
}

private void tcp1_EndSend(object sender, Dart.PowerTCP.SegmentEventArgs e)
{
    // Check for exception
    if(e.Exception == null)
    {
        // Send is complete. Display info about the data sent.
        Debug.WriteLine("Byte count sent: " + e.Segment.Count);
        Debug.WriteLine("Data sent: " + e.Segment.ToString());

        byte[] buffer = new byte[tcp1.ReceiveBufferSize];

        // Receive the data. The EndReceive event will be raised upon completion.
        tcp1.BeginReceive(buffer, 0, buffer.Length, System.Net.Sockets.SocketFlags.None, null);
    }
}

private void tcp1_EndReceive(object sender, Dart.PowerTCP.SegmentEventArgs e)
{
    // Check for exception
    if(e.Exception == null)
    {
        // Receive is complete. Display info about the data sent.
        Debug.WriteLine("Byte count received: " + e.Segment.Count);
        Debug.WriteLine("Data received: " + e.Segment.ToString());

        // Close the connection
        tcp1.Close();
    }
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace | Tcp.BeginReceive Overload List


Tcp.BeginReceive Method (Byte[], Int32, Int32, SocketFlags, Object)

Receive data into your buffer asynchronously specifying a buffer, offset, size and SocketFlags value. The Tcp.EndReceive event is raised when completed.

[Visual Basic]
Overloads Public Function BeginReceive( _
ByVal buffer As Byte(), _
ByVal offset As Integer, _
ByVal size As Integer, _
ByVal socketFlags As SocketFlags, _
ByVal state As Object _
) As IAsyncResult
[C#]
public IAsyncResult BeginReceive(
byte[] buffer,
int offset,
int size,
SocketFlags socketFlags,
object state
);

Parameters

buffer
Destination memory location to store received data.
offset
Starting offset within buffer for filling.
size
Maximum number of bytes to receive.
socketFlags
A bitwise combination of special use receiving parameters.
state
User state information.

Return Value

An IAsyncResult that represents the asynchronous operation, which could still be pending.

Remarks

The Tcp.BeginReceive method is used to receive data into a buffer asynchronously. When data has been received, the Tcp.EndReceive event is raised. A SegmentEventArgs object is passed into this event, containing a Segment object which encaspsulates information about the data itself and the amount of bytes of data received.

The object state is useful for any kind of state information you would like accessible in the Tcp.EndReceive event. Since the method is "disconnected" from the calling code and returns to the calling thread elsewhere, you may wish to pass an object/variable as state to be retrieved and used in the event handler.

If you are using the Tcp component as a reference, you must "wire up" the event yourself. This involves creating a method as the event handler that implements the SegmentEventHandler delegate.

To synchronously receive data, use the Tcp.Receive method.

Use this method if you wish to receive data into your buffer transparently with minimal application impact, as execution occurs on another thread. This method allows for greater configuration over how the data is received. For example, you could specify SocketFlags.Peek to peek at an incoming message. Also, if you would like to perform an asynchronous receive and make user defined objects available in the Tcp.EndReceive event (via the state object), you must use this method.

Exceptions

Exception Type | Condition
InvalidOperationException | BeginXXX method used without providing an EndXXX event handler.
IOException | The stream is not Readable.
ArgumentNullException | buffer is null.
ArgumentOutOfRangeException | offset or size is less than 0.
ArgumentException | offset + size is greater than the length of buffer.
SocketException | The socket is not connected.

Example

[Visual Basic, C#] The following example demonstrates asynchronous receiving and sending of data.

[Visual Basic]
Private Sub AsynchTcpDemo()

   ' Attempt to connect to an echo port.
   Try
      Tcp1.Connect("myserver", 7)
   Catch ex As Exception
      Return
   End Try

   ' Send data, since we are connected to an echo port, the same data should be returned.
   ' The following code demonstrates asynchronously sending data. When data has been sent
   ' the EndSend event will be raised.

   Dim buffer() As Byte = System.Text.Encoding.Default.GetBytes("a")
   Tcp1.BeginSend(buffer, 0, buffer.Length, Net.Sockets.SocketFlags.None, Nothing)
End Sub

Private Sub Tcp1_EndSend(ByVal sender As Object, ByVal e As Dart.PowerTCP.SegmentEventArgs) Handles Tcp1.EndSend
   ' Check for exception
   If e.Exception Is Nothing Then

      ' Send is complete. Display info about the data sent.
      Debug.WriteLine("Byte count sent: " + e.Segment.Count)
      Debug.WriteLine("Data sent: " + e.Segment.ToString())

      Dim buffer(Tcp1.ReceiveBufferSize) As Byte

      ' Receive the data. The EndReceive event will be raised upon completion.
      Tcp1.BeginReceive(buffer, 0, buffer.Length, Net.Sockets.SocketFlags.None, Nothing)

    End If
End Sub

Private Sub Tcp1_EndReceive(ByVal sender As Object, ByVal e As Dart.PowerTCP.SegmentEventArgs) Handles Tcp1.EndReceive
   ' Check for exception
   If e.Exception Is Nothing Then

      ' Receive is complete. Display info about the data sent.
      Debug.WriteLine("Byte count received: " + e.Segment.Count)
      Debug.WriteLine("Data received: " + e.Segment.ToString())

      ' Close the connection
      Tcp1.Close()
    End If
End Sub
[C#]
private void AsynchTcpDemo()
{
    // Attempt to connect to an echo port.
    try
    {
        tcp1.Connect("myserver", 7);
    }
    catch(Exception ex)
    {return;}

    // Send data, since we are connected to an echo port, the same data should be returned.
    // The following code demonstrates asynchronously sending data. When data has been sent
    // the EndSend event will be raised.

    byte[] buffer = System.Text.Encoding.Default.GetBytes("a");
    tcp1.BeginSend(buffer, 0, buffer.Length, System.Net.Sockets.SocketFlags.None, null);
}

private void tcp1_EndSend(object sender, Dart.PowerTCP.SegmentEventArgs e)
{
    // Check for exception
    if(e.Exception == null)
    {
        // Send is complete. Display info about the data sent.
        Debug.WriteLine("Byte count sent: " + e.Segment.Count);
        Debug.WriteLine("Data sent: " + e.Segment.ToString());

        byte[] buffer = new byte[tcp1.ReceiveBufferSize];

        // Receive the data. The EndReceive event will be raised upon completion.
        tcp1.BeginReceive(buffer, 0, buffer.Length, System.Net.Sockets.SocketFlags.None, null);
    }
}

private void tcp1_EndReceive(object sender, Dart.PowerTCP.SegmentEventArgs e)
{
    // Check for exception
    if(e.Exception == null)
    {
        // Receive is complete. Display info about the data sent.
        Debug.WriteLine("Byte count received: " + e.Segment.Count);
        Debug.WriteLine("Data received: " + e.Segment.ToString());

        // Close the connection
        tcp1.Close();
    }
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace | Tcp.BeginReceive Overload List


BeginSend Method

PowerTCP Telnet for .NET

Tcp.BeginSend Method

Send data from your buffer asynchronously. The Tcp.EndSend event is raised when completed.

Overload List

Send data from your buffer asynchronously. The Tcp.EndSend event is raised when completed.

public IAsyncResult BeginSend(byte[]);

Send data from your buffer asynchronously, specifying a buffer, offset, size and SocketFlags value. The Tcp.EndSend event is raised when completed.

public IAsyncResult BeginSend(byte[],int,int,SocketFlags,object);

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.BeginSend Method (Byte[])

Send data from your buffer asynchronously. The Tcp.EndSend event is raised when completed.

[Visual Basic]
Overloads Public Function BeginSend( _
ByVal buffer As Byte() _
) As IAsyncResult
[C#]
public IAsyncResult BeginSend(
byte[] buffer
);

Parameters

buffer
Source memory location for the data to send.

Return Value

An IAsyncResult that represents the asynchronous operation, which could still be pending.

Remarks

The Tcp.BeginSend method is used to send data from a buffer asynchronously. When the data has been sent, the Tcp.EndSend event is raised. A SegmentEventArgs object is passed into this event, containing a Segment object, containing information about the data sent, including the data itself and the amount of bytes of data sent.

If you are using the Tcp component as a reference, you must "wire up" the event yourself. This involves creating a method as the event handler that implements the SegmentEventHandler delegate.

To synchronously send data, use the Tcp.Send method.

Use this method if you wish to receive data into a buffer transparently with minimal application impact, as execution occurs on another thread. This method is the standard means for asynchronously sending data.

Exceptions

Exception Type | Condition
InvalidOperationException | BeginXXX method used without providing an EndXXX event handler.
ArgumentOutOfRangeException | offset or size is less than 0.
ArgumentException | offset + size is greater than the length of buffer.
SocketException | The socket is not connected.

Example

[Visual Basic, C#] The following example demonstrates asynchronous receiving and sending of data.

[Visual Basic]
Private Sub AsynchTcpDemo()

   ' Attempt to connect to an echo port.
   Try
      Tcp1.Connect("myserver", 7)
   Catch ex As Exception
      Return
   End Try

   ' Send data, since we are connected to an echo port, the same data should be returned.
   ' The following code demonstrates asynchronously sending data. When data has been sent
   ' the EndSend event will be raised.

   Dim buffer() As Byte = System.Text.Encoding.Default.GetBytes("a")
   Tcp1.BeginSend(buffer, 0, buffer.Length, Net.Sockets.SocketFlags.None, Nothing)
End Sub

Private Sub Tcp1_EndSend(ByVal sender As Object, ByVal e As Dart.PowerTCP.SegmentEventArgs) Handles Tcp1.EndSend
   ' Check for exception
   If e.Exception Is Nothing Then

      ' Send is complete. Display info about the data sent.
      Debug.WriteLine("Byte count sent: " + e.Segment.Count)
      Debug.WriteLine("Data sent: " + e.Segment.ToString())

      Dim buffer(Tcp1.ReceiveBufferSize) As Byte

      ' Receive the data. The EndReceive event will be raised upon completion.
      Tcp1.BeginReceive(buffer, 0, buffer.Length, Net.Sockets.SocketFlags.None, Nothing)

    End If
End Sub

Private Sub Tcp1_EndReceive(ByVal sender As Object, ByVal e As Dart.PowerTCP.SegmentEventArgs) Handles Tcp1.EndReceive
   ' Check for exception
   If e.Exception Is Nothing Then

      ' Receive is complete. Display info about the data sent.
      Debug.WriteLine("Byte count received: " + e.Segment.Count)
      Debug.WriteLine("Data received: " + e.Segment.ToString())

      ' Close the connection
      Tcp1.Close()
    End If
End Sub
[C#]
private void AsynchTcpDemo()
{
    // Attempt to connect to an echo port.
    try
    {
        tcp1.Connect("myserver", 7);
    }
    catch(Exception ex)
    {return;}

    // Send data, since we are connected to an echo port, the same data should be returned.
    // The following code demonstrates asynchronously sending data. When data has been sent
    // the EndSend event will be raised.

    byte[] buffer = System.Text.Encoding.Default.GetBytes("a");
    tcp1.BeginSend(buffer, 0, buffer.Length, System.Net.Sockets.SocketFlags.None, null);
}

private void tcp1_EndSend(object sender, Dart.PowerTCP.SegmentEventArgs e)
{
    // Check for exception
    if(e.Exception == null)
    {
        // Send is complete. Display info about the data sent.
        Debug.WriteLine("Byte count sent: " + e.Segment.Count);
        Debug.WriteLine("Data sent: " + e.Segment.ToString());

        byte[] buffer = new byte[tcp1.ReceiveBufferSize];

        // Receive the data. The EndReceive event will be raised upon completion.
        tcp1.BeginReceive(buffer, 0, buffer.Length, System.Net.Sockets.SocketFlags.None, null);
    }
}

private void tcp1_EndReceive(object sender, Dart.PowerTCP.SegmentEventArgs e)
{
    // Check for exception
    if(e.Exception == null)
    {
        // Receive is complete. Display info about the data sent.
        Debug.WriteLine("Byte count received: " + e.Segment.Count);
        Debug.WriteLine("Data received: " + e.Segment.ToString());

        // Close the connection
        tcp1.Close();
    }
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace | Tcp.BeginSend Overload List


Tcp.BeginSend Method (Byte[], Int32, Int32, SocketFlags, Object)

Send data from your buffer asynchronously, specifying a buffer, offset, size and SocketFlags value. The Tcp.EndSend event is raised when completed.

[Visual Basic]
Overloads Public Function BeginSend( _
ByVal buffer As Byte(), _
ByVal offset As Integer, _
ByVal size As Integer, _
ByVal socketFlags As SocketFlags, _
ByVal state As Object _
) As IAsyncResult
[C#]
public IAsyncResult BeginSend(
byte[] buffer,
int offset,
int size,
SocketFlags socketFlags,
object state
);

Parameters

buffer
Source memory location for the data to send.
offset
Starting offset within buffer for sending.
size
Number of bytes to send.
socketFlags
Bitwise combination of special use sending parameters.
state
User state information.

Return Value

An IAsyncResult that represents the asynchronous operation, which could still be pending.

Remarks

The Tcp.BeginSend method is used to send data from a buffer asynchronously. When the data has been sent, the Tcp.EndSend event is raised. A SegmentEventArgs object is passed into this event, containing a Segment object, containing information about the data sent, including the data itself and the amount of bytes of data sent.

If you are using the Tcp component as a reference, you must "wire up" the event yourself. This involves creating a method as the event handler that implements the SegmentEventHandler delegate.

To synchronously send data, use the Tcp.Send method.

Use this method if you wish to receive data into a buffer transparently with minimal application impact, as execution occurs on another thread. This method allows for greater configuration over how the data is sent. For example, you could specify SocketFlags.DontRoute to specify to send without using routing tables. Also, if you would like to perform an asynchronous send and make user defined data available in the EndSend event, you must use this method.

Exceptions

Exception Type | Condition
InvalidOperationException | BeginXXX method used without providing an EndXXX event handler.
ArgumentOutOfRangeException | offset or size is less than 0.
ArgumentException | offset + size is greater than the length of buffer.
SocketException | The socket is not connected.

Example

[Visual Basic, C#] The following example demonstrates asynchronous receiving and sending of data.

[Visual Basic]
Private Sub AsynchTcpDemo()

   ' Attempt to connect to an echo port.
   Try
      Tcp1.Connect("myserver", 7)
   Catch ex As Exception
      Return
   End Try

   ' Send data, since we are connected to an echo port, the same data should be returned.
   ' The following code demonstrates asynchronously sending data. When data has been sent
   ' the EndSend event will be raised.

   Dim buffer() As Byte = System.Text.Encoding.Default.GetBytes("a")
   Tcp1.BeginSend(buffer, 0, buffer.Length, Net.Sockets.SocketFlags.None, Nothing)
End Sub

Private Sub Tcp1_EndSend(ByVal sender As Object, ByVal e As Dart.PowerTCP.SegmentEventArgs) Handles Tcp1.EndSend
   ' Check for exception
   If e.Exception Is Nothing Then

      ' Send is complete. Display info about the data sent.
      Debug.WriteLine("Byte count sent: " + e.Segment.Count)
      Debug.WriteLine("Data sent: " + e.Segment.ToString())

      Dim buffer(Tcp1.ReceiveBufferSize) As Byte

      ' Receive the data. The EndReceive event will be raised upon completion.
      Tcp1.BeginReceive(buffer, 0, buffer.Length, Net.Sockets.SocketFlags.None, Nothing)

    End If
End Sub

Private Sub Tcp1_EndReceive(ByVal sender As Object, ByVal e As Dart.PowerTCP.SegmentEventArgs) Handles Tcp1.EndReceive
   ' Check for exception
   If e.Exception Is Nothing Then

      ' Receive is complete. Display info about the data sent.
      Debug.WriteLine("Byte count received: " + e.Segment.Count)
      Debug.WriteLine("Data received: " + e.Segment.ToString())

      ' Close the connection
      Tcp1.Close()
    End If
End Sub
[C#]
private void AsynchTcpDemo()
{
    // Attempt to connect to an echo port.
    try
    {
        tcp1.Connect("myserver", 7);
    }
    catch(Exception ex)
    {return;}

    // Send data, since we are connected to an echo port, the same data should be returned.
    // The following code demonstrates asynchronously sending data. When data has been sent
    // the EndSend event will be raised.

    byte[] buffer = System.Text.Encoding.Default.GetBytes("a");
    tcp1.BeginSend(buffer, 0, buffer.Length, System.Net.Sockets.SocketFlags.None, null);
}

private void tcp1_EndSend(object sender, Dart.PowerTCP.SegmentEventArgs e)
{
    // Check for exception
    if(e.Exception == null)
    {
        // Send is complete. Display info about the data sent.
        Debug.WriteLine("Byte count sent: " + e.Segment.Count);
        Debug.WriteLine("Data sent: " + e.Segment.ToString());

        byte[] buffer = new byte[tcp1.ReceiveBufferSize];

        // Receive the data. The EndReceive event will be raised upon completion.
        tcp1.BeginReceive(buffer, 0, buffer.Length, System.Net.Sockets.SocketFlags.None, null);
    }
}

private void tcp1_EndReceive(object sender, Dart.PowerTCP.SegmentEventArgs e)
{
    // Check for exception
    if(e.Exception == null)
    {
        // Receive is complete. Display info about the data sent.
        Debug.WriteLine("Byte count received: " + e.Segment.Count);
        Debug.WriteLine("Data received: " + e.Segment.ToString());

        // Close the connection
        tcp1.Close();
    }
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace | Tcp.BeginSend Overload List


Close Method

PowerTCP Telnet for .NET

Tcp.Close Method

Close the connection.

Overload List

Close the connection.

public void Close();

Close the connection.

public void Close(LingerOption);

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.Close Method ()

Close the connection.

[Visual Basic]
Overloads Public Sub Close()
[C#]
public void Close();

Remarks

This method is the recommended way to explicitly close a connection. The Tcp.Connected property is set to false when the connection is closed.

Example

[Visual Basic, C#] The following example demonstrates connecting to an echo port, sending data, receiving data, then closing the connection.

[Visual Basic]
Private Sub TcpDemo()

   ' Connect to echo port.
   Tcp1.Connect("atropos", "7")

   ' Send some data
   Dim seg As Segment = Tcp1.Send("Hello")

   ' Display info
   Debug.WriteLine("Bytes of data sent: " & seg.Count)
   Debug.WriteLine("Data sent: " & seg.ToString())

   ' Receive response (this should be the same as the sent data)
   seg = Tcp1.Receive()

   ' Display info
   Debug.WriteLine("Bytes of data received: " & seg.Count)
   Debug.WriteLine("Data received: " & seg.ToString())

   ' Since connection is to an echo port, the client has to
   ' close the connection.
   Try
      Tcp1.Close()
   Catch ex As Exception
      ' Error, just dispose the object.
      Tcp1.Dispose()
   End Try

   '* Output
   '* --------------------------
   '* Bytes of data sent: 5
   '* Data sent: Hello
   '* Bytes of data received: 5
   '* Data received: Hello
   '*
End Sub
[C#]
private void TcpDemo()
{
   // Connect to echo port.
   tcp1.Connect("atropos", "7");

   // Send some data
   Segment seg = tcp1.Send("Hello");

   // Display info
   Debug.WriteLine("Bytes of data sent: " + seg.Count);
   Debug.WriteLine("Data sent: " + seg.ToString());

   // Receive response (this should be the same as the sent data)
   seg = tcp1.Receive();

   // Display info
   Debug.WriteLine("Bytes of data received: " + seg.Count);
   Debug.WriteLine("Data received: " + seg.ToString());

   // Since connection is to an echo port, the client has to
   // close the connection.
   try
   {
      tcp1.Close();
   }
   catch(Exception ex)
   {
      // Error, just dispose the object.
      tcp1.Dispose();
   }

   /* Output
    * --------------------------
    * Bytes of data sent: 5
    * Data sent: Hello
    * Bytes of data received: 5
    * Data received: Hello
    */
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace | Tcp.Close Overload List


Tcp.Close Method (LingerOption)

Close the connection.

[Visual Basic]
Overloads Public Sub Close( _
ByVal linger As LingerOption _
)
[C#]
public void Close(
LingerOption linger
);

Parameters

linger
If null is used, a graceful disconnect will occur without blocking execution of your application.

Remarks

This method is the recommended way to explicitly close a connection. The Tcp.Connected property is set to false when the connection is closed.

The LingerOption parameter controls the amount of time to remain connected after the socket is closed.

Example

[Visual Basic, C#] The following example demonstrates connecting to an echo port, sending data, receiving data, then closing the connection.

[Visual Basic]
Private Sub TcpDemo()

   ' Connect to echo port.
   Tcp1.Connect("atropos", "7")

   ' Send some data
   Dim seg As Segment = Tcp1.Send("Hello")

   ' Display info
   Debug.WriteLine("Bytes of data sent: " & seg.Count)
   Debug.WriteLine("Data sent: " & seg.ToString())

   ' Receive response (this should be the same as the sent data)
   seg = Tcp1.Receive()

   ' Display info
   Debug.WriteLine("Bytes of data received: " & seg.Count)
   Debug.WriteLine("Data received: " & seg.ToString())

   ' Since connection is to an echo port, the client has to
   ' close the connection.
   Try
      Tcp1.Close()
   Catch ex As Exception
      ' Error, just dispose the object.
      Tcp1.Dispose()
   End Try

   '* Output
   '* --------------------------
   '* Bytes of data sent: 5
   '* Data sent: Hello
   '* Bytes of data received: 5
   '* Data received: Hello
   '*
End Sub
[C#]
private void TcpDemo()
{
   // Connect to echo port.
   tcp1.Connect("atropos", "7");

   // Send some data
   Segment seg = tcp1.Send("Hello");

   // Display info
   Debug.WriteLine("Bytes of data sent: " + seg.Count);
   Debug.WriteLine("Data sent: " + seg.ToString());

   // Receive response (this should be the same as the sent data)
   seg = tcp1.Receive();

   // Display info
   Debug.WriteLine("Bytes of data received: " + seg.Count);
   Debug.WriteLine("Data received: " + seg.ToString());

   // Since connection is to an echo port, the client has to
   // close the connection.
   try
   {
      tcp1.Close();
   }
   catch(Exception ex)
   {
      // Error, just dispose the object.
      tcp1.Dispose();
   }

   /* Output
    * --------------------------
    * Bytes of data sent: 5
    * Data sent: Hello
    * Bytes of data received: 5
    * Data received: Hello
    */
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace | Tcp.Close Overload List


Connect Method

PowerTCP Telnet for .NET

Tcp.Connect Method

Connect to a host.

Overload List

Connect to a host.

public void Connect(string,int);

Connect to a host, specifying the local interface to use.

public void Connect(string,int,string,int);

Connect to a host, specifying the local interface and a range of local ports to use.

public virtual void Connect(string,int,string,int,int);

Connect to a host.

public void Connect(string,string);

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.Connect Method (String, Int32)

Connect to a host.

[Visual Basic]
Overloads Public Sub Connect( _
ByVal server As String, _
ByVal serverPort As Integer _
)
[C#]
public void Connect(
string server,
int serverPort
);

Parameters

server
Remote hostname or address in dot notation.
serverPort
Remote port, a number between 1 and 65535, inclusive.

Remarks

The Tcp.Connect method establishes a network connection between the default local network interface/port and the device identified by remote network address/port. If no exception is thrown, the connection has succeeded and the Tcp.Connected property will return true after this method returns. Once the connection has been made, you can send/receive data to/from the server.

This method always blocks until the attempted connection succeeds or fails.

Example

[Visual Basic, C#] The following example demonstrates connecting implementing the SMTP protocol using the Tcp component to send a simple message.

[Visual Basic]
Private Sub TcpDemo()

   ' The following code assumes that good responses are always received from
   ' the server. More robust code should check each response and handle appropriately.

   ' Connect to SMTP port
   Tcp1.Connect("mail", 25)

   ' Send the EHLO command
   Tcp1.Send("EHLO myserver" + vbCrLf)

   ' Get response from the server
   Dim seg As Segment = Tcp1.Receive()

   ' Send MAIL FROM command
   Tcp1.Send("MAIL FROM: test@myserver.com" + vbCrLf)

   ' Get response from the server
   seg = Tcp1.Receive()

   ' Send RCPT TO command
   Tcp1.Send("RCPT TO: you@yourserver.com" + vbCrLf)

   ' Get response from the server
   seg = Tcp1.Receive()

   ' Send DATA command
   Tcp1.Send("DATA" + vbCrLf)

   ' Get response from the server
   seg = Tcp1.Receive()

   ' Send DATA
   Tcp1.Send("Test Message" + vbCrLf + "." + vbCrLf)

   ' Receive response from the server
   seg = Tcp1.Receive()

   ' Write output
   Debug.WriteLine("Operation complete. The following information")
   Debug.WriteLine("was reported by the server:")
   Debug.WriteLine(seg.ToString())
End Sub
[C#]
private void TcpDemo()
{

   // The following code assumes that good responses are always received from
   // the server. More robust code should check each response and handle appropriately.

   // Connect to SMTP port
   tcp1.Connect("mail", 25);

   // Send the EHLO command
   tcp1.Send("EHLO myserver\r\n");

   // Get response from the server
   Segment seg = tcp1.Receive();

   // Send MAIL FROM command
   tcp1.Send("MAIL FROM: test@myserver.com\r\n");

   // Get response from the server
   seg = tcp1.Receive();

   // Send RCPT TO command
   tcp1.Send("RCPT TO: you@yourserver.com\r\n");

   // Get response from the server
   seg = tcp1.Receive();

   // Send DATA command
   tcp1.Send("DATA\r\n");

   // Get response from the server
   seg = tcp1.Receive();

   // Send DATA
   tcp1.Send("Test Message\r\n.\r\n");

   // Receive response from the server
   seg = tcp1.Receive();

   // Write output
   Debug.WriteLine("Operation complete. The following information");
   Debug.WriteLine("was reported by the server about the operation:");
   Debug.WriteLine(seg.ToString());
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace | Tcp.Connect Overload List


Tcp.Connect Method (String, Int32, String, Int32)

Connect to a host, specifying the local interface to use.

[Visual Basic]
Overloads Public Sub Connect( _
ByVal server As String, _
ByVal serverPort As Integer, _
ByVal client As String, _
ByVal clientPort As Integer _
)
[C#]
public void Connect(
string server,
int serverPort,
string client,
int clientPort
);

Parameters

server
Remote hostname or address in dot notation.
serverPort
Remote port, a number between 1 and 65535, inclusive.
client
Optional local hostname or address in dot notation. Use "" as default.
clientPort
Optional local port, a number between 1 and 65535, inclusive. Use 0 as default.

Remarks

The Tcp.Connect method establishes a network connection between the specified local network interface/port and the device identified by remote network address/port. If no exception is thrown, the connection has succeeded and the Tcp.Connected property will return true after this method returns. Once the connection has been made, you can send/receive data to/from the server.

This method always blocks until the attempted connection succeeds or fails.

Example

[Visual Basic, C#] The following example demonstrates connecting to a server while specifying a local interface to use.

[Visual Basic]
' Connect to the server, specifying the local interface to use
Tcp1.Connect("atropos", 13, "192.168.0.83", 8888)

' Since connection was to DAYTIME port (13), simply receive the time
Dim seg As Segment = Tcp1.Receive()

Debug.WriteLine("Time reported by server: " + seg.ToString())
[C#]
// Connect to the server, specifying the local interface to use
tcp1.Connect("atropos", 13, "192.168.0.83", 8888);

// Since connection was to DAYTIME port (13), simply receive the time
Segment seg = tcp1.Receive();

Debug.WriteLine("Time reported by server: " + seg.ToString());

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace | Tcp.Connect Overload List


Tcp.Connect Method (String, Int32, String, Int32, Int32)

Connect to a host, specifying the local interface and a range of local ports to use.

[Visual Basic]
Overridable Overloads Public Sub Connect( _
ByVal server As String, _
ByVal serverPort As Integer, _
ByVal client As String, _
ByVal clientPortMin As Integer, _
ByVal clientPortMax As Integer _
)
[C#]
public virtual void Connect(
string server,
int serverPort,
string client,
int clientPortMin,
int clientPortMax
);

Parameters

server
Remote hostname or address in dot notation.
serverPort
Remote port, a number between 1 and 65535, inclusive.
client
Optional local hostname or address in dot notation. Use "" as default.
clientPortMin
The minimum client port number to use as a local interface.
clientPortMax
The maximum client port number to use as a local interface.

Remarks

The Tcp.Connect method establishes a network connection between the specified local network interface/port and the device identified by remote network address/port. If no exception is thrown, the connection has succeeded and the Tcp.Connected property will return true after this method returns. Once the connection has been made, you can send/receive data to/from the server.

This method always blocks until the attempted connection succeeds or fails.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace | Tcp.Connect Overload List


Tcp.Connect Method (String, String)

Connect to a host.

[Visual Basic]
Overloads Public Sub Connect( _
ByVal server As String, _
ByVal serverPort As String _
)
[C#]
public void Connect(
string server,
string serverPort
);

Parameters

server
Remote hostname or address in dot notation.
serverPort
A string value which can be cast to an Integer between 1 and 65535, inclusive.

Remarks

The Tcp.Connect method establishes a network connection between the default local network interface/port and the device identified by remote network address/port. If no exception is thrown, the connection has succeeded and the Tcp.Connected property will return true after this method returns. Once the connection has been made, you can send/receive data to/from the server.

This method always blocks until the attempted connection succeeds or fails.

Example

[Visual Basic, C#] The following example demonstrates connecting to an echo port, sending data, receiving data, then closing the connection.

[Visual Basic]
Private Sub TcpDemo()

   ' Connect to echo port.
   Tcp1.Connect("atropos", "7")

   ' Send some data
   Dim seg As Segment = Tcp1.Send("Hello")

   ' Display info
   Debug.WriteLine("Bytes of data sent: " & seg.Count)
   Debug.WriteLine("Data sent: " & seg.ToString())

   ' Receive response (this should be the same as the sent data)
   seg = Tcp1.Receive()

   ' Display info
   Debug.WriteLine("Bytes of data received: " & seg.Count)
   Debug.WriteLine("Data received: " & seg.ToString())

   ' Since connection is to an echo port, the client has to
   ' close the connection.
   Try
      Tcp1.Close()
   Catch ex As Exception
      ' Error, just dispose the object.
      Tcp1.Dispose()
   End Try

   '* Output
   '* --------------------------
   '* Bytes of data sent: 5
   '* Data sent: Hello
   '* Bytes of data received: 5
   '* Data received: Hello
   '*
End Sub
[C#]
private void TcpDemo()
{
   // Connect to echo port.
   tcp1.Connect("atropos", "7");

   // Send some data
   Segment seg = tcp1.Send("Hello");

   // Display info
   Debug.WriteLine("Bytes of data sent: " + seg.Count);
   Debug.WriteLine("Data sent: " + seg.ToString());

   // Receive response (this should be the same as the sent data)
   seg = tcp1.Receive();

   // Display info
   Debug.WriteLine("Bytes of data received: " + seg.Count);
   Debug.WriteLine("Data received: " + seg.ToString());

   // Since connection is to an echo port, the client has to
   // close the connection.
   try
   {
      tcp1.Close();
   }
   catch(Exception ex)
   {
      // Error, just dispose the object.
      tcp1.Dispose();
   }

   /* Output
    * --------------------------
    * Bytes of data sent: 5
    * Data sent: Hello
    * Bytes of data received: 5
    * Data received: Hello
    */
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace | Tcp.Connect Overload List


Receive Method

PowerTCP Telnet for .NET

Tcp.Receive Method

Receive data from the host.

Overload List

Receive data from the host.

public Segment Receive();

Receive data from the host.

public Segment Receive(byte[]);

Receive data from the host, specifying a buffer, offset, size and SocketFlags value.

public Segment Receive(byte[],int,int,SocketFlags);

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.Receive Method ()

Receive data from the host.

[Visual Basic]
Overloads Public Function Receive() As Segment
[C#]
public Segment Receive();

Return Value

A Segment object encapsulating the data received.

Remarks

After connecting, data can be received using the Tcp.Recieve method. All Tcp.Receive methods return a Segment object, encapsulating the data received. In order to access the data, simply access the properties of the Segment object returned such as Segment.Buffer (to access the data in a byte array) or Segment.ToString (to access the data as a string).

If the amount of data received from the server exceeds Tcp.ReceiveBufferSize, the Tcp.Receive method will have to be called multiple times until the socket closes.

This method is functionally equivalent to Tcp.Stream.Write().

Exceptions

Exception Type | Condition
IOException | The stream is not Readable.
ArgumentNullException | buffer is null.
ArgumentOutOfRangeException | offset or size is less than 0.
ArgumentException | offset + size is greater than the length of buffer.
SocketException | The socket is not connected.

Example

[Visual Basic, C#] The following example demonstrates connecting implementing the SMTP protocol using the Tcp component to send a simple message.

[Visual Basic]
Private Sub TcpDemo()

   ' The following code assumes that good responses are always received from
   ' the server. More robust code should check each response and handle appropriately.

   ' Connect to SMTP port
   Tcp1.Connect("mail", 25)

   ' Send the EHLO command
   Tcp1.Send("EHLO myserver" + vbCrLf)

   ' Get response from the server
   Dim seg As Segment = Tcp1.Receive()

   ' Send MAIL FROM command
   Tcp1.Send("MAIL FROM: test@myserver.com" + vbCrLf)

   ' Get response from the server
   seg = Tcp1.Receive()

   ' Send RCPT TO command
   Tcp1.Send("RCPT TO: you@yourserver.com" + vbCrLf)

   ' Get response from the server
   seg = Tcp1.Receive()

   ' Send DATA command
   Tcp1.Send("DATA" + vbCrLf)

   ' Get response from the server
   seg = Tcp1.Receive()

   ' Send DATA
   Tcp1.Send("Test Message" + vbCrLf + "." + vbCrLf)

   ' Receive response from the server
   seg = Tcp1.Receive()

   ' Write output
   Debug.WriteLine("Operation complete. The following information")
   Debug.WriteLine("was reported by the server:")
   Debug.WriteLine(seg.ToString())
End Sub
[C#]
private void TcpDemo()
{

   // The following code assumes that good responses are always received from
   // the server. More robust code should check each response and handle appropriately.

   // Connect to SMTP port
   tcp1.Connect("mail", 25);

   // Send the EHLO command
   tcp1.Send("EHLO myserver\r\n");

   // Get response from the server
   Segment seg = tcp1.Receive();

   // Send MAIL FROM command
   tcp1.Send("MAIL FROM: test@myserver.com\r\n");

   // Get response from the server
   seg = tcp1.Receive();

   // Send RCPT TO command
   tcp1.Send("RCPT TO: you@yourserver.com\r\n");

   // Get response from the server
   seg = tcp1.Receive();

   // Send DATA command
   tcp1.Send("DATA\r\n");

   // Get response from the server
   seg = tcp1.Receive();

   // Send DATA
   tcp1.Send("Test Message\r\n.\r\n");

   // Receive response from the server
   seg = tcp1.Receive();

   // Write output
   Debug.WriteLine("Operation complete. The following information");
   Debug.WriteLine("was reported by the server about the operation:");
   Debug.WriteLine(seg.ToString());
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace | Tcp.Receive Overload List


Tcp.Receive Method (Byte[])

Receive data from the host.

[Visual Basic]
Overloads Public Function Receive( _
ByVal buffer As Byte() _
) As Segment
[C#]
public Segment Receive(
byte[] buffer
);

Parameters

buffer
Destination memory location to store received data.

Return Value

A Segment object encapsulating the data received.

Remarks

After connecting, data can be received using the Tcp.Recieve method. All Tcp.Receive methods return a Segment object, encapsulating the data received. In order to access the data, simply access the properties of the Segment object returned such as Segment.Buffer (to access the data in a byte array) or Segment.ToString (to access the data as a string).

If the amount of data received from the server exceeds Tcp.ReceiveBufferSize, the Tcp.Receive method will have to be called multiple times until the socket closes.

This method is functionally equivalent to Tcp.Stream.Write(byte[]).

Exceptions

Exception Type | Condition
IOException | The stream is not Readable.
ArgumentNullException | buffer is null.
ArgumentOutOfRangeException | offset or size is less than 0.
ArgumentException | offset + size is greater than the length of buffer.
SocketException | The socket is not connected.

Example

[Visual Basic, C#] The following example demonstrates sending bytes to the server.

[Visual Basic]
Private Sub Test()
   ' Connect to an echo port
   Tcp1.Connect("atropos", 7)

   Dim sendbuffer() As Byte = System.Text.Encoding.Default.GetBytes("abcdefg")

   ' Send some bytes.
   Tcp1.Send(sendbuffer)

   Dim recvbuffer(sendbuffer.Length) As Byte

   ' Server will echo the bytes back. Receive the bytes.
   Tcp1.Receive(recvbuffer)

   ' Close the connection.
   Tcp1.Close()
End Sub
[C#]
private void Test()
{
   // Connect to the echo port
   tcp1.Connect("atropos", 7);

   byte[] sendbuffer = System.Text.Encoding.Default.GetBytes("abcdefg");

   // Send some bytes.
   tcp1.Send(sendbuffer);

   byte[] recvbuffer = new byte[sendbuffer.Length];

   // Server will echo the bytes back. Receive the bytes.
   tcp1.Receive(recvbuffer);

   // Close the connection.
   tcp1.Close();
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace | Tcp.Receive Overload List


Tcp.Receive Method (Byte[], Int32, Int32, SocketFlags)

Receive data from the host, specifying a buffer, offset, size and SocketFlags value.

[Visual Basic]
Overloads Public Function Receive( _
ByVal buffer As Byte(), _
ByVal offset As Integer, _
ByVal size As Integer, _
ByVal socketFlags As SocketFlags _
) As Segment
[C#]
public Segment Receive(
byte[] buffer,
int offset,
int size,
SocketFlags socketFlags
);

Parameters

buffer
Destination memory location to store received data.
offset
Starting offset within buffer for filling.
size
Maximum number of bytes to receive.
socketFlags
A bitwise combination of special use receiving parameters.

Return Value

A Segment object encapsulating the data received.

Remarks

After connecting, data can be received using the Tcp.Recieve method. All Tcp.Receive methods return a Segment object, encapsulating the data received. In order to access the data, simply access the properties of the Segment object returned such as Segment.Buffer (to access the data in a byte array) or Segment.ToString (to access the data as a string).

This method is the only way to receive data from a host while specifying a SocketFlags parameter.

Exceptions

Exception Type | Condition
IOException | The stream is not Readable.
ArgumentNullException | buffer is null.
ArgumentOutOfRangeException | offset or size is less than 0.
ArgumentException | offset + size is greater than the length of buffer.
SocketException | The socket is not connected.

Example

[Visual Basic, C#] The following example demonstrates sending bytes to the server with a SocketFlag option.

[Visual Basic]
Private Sub Test()
   ' Connect to an echo port
   Tcp1.Connect("atropos", 7)

   Dim sendbuffer() As Byte = System.Text.Encoding.Default.GetBytes("abcdefg")

   ' Send some bytes with "OutOfBand" SocketFlag option
   Tcp1.Send(sendbuffer, 0, sendbuffer.Length, SocketFlags.OutOfBand)

   Dim recvbuffer(sendbuffer.Length) As Byte

   ' Server will echo the bytes back. Receive the bytes.
   Tcp1.Receive(recvbuffer, 0, recvbuffer.Length, SocketFlags.None)

   ' Close the connection.
   Tcp1.Close()
End Sub
[C#]
private void Test()
{
   // Connect to the echo port
   tcp1.Connect("atropos", 7);

   byte[] sendbuffer = System.Text.Encoding.Default.GetBytes("abcdefg");

   // Send some bytes with "OutOfBand" SocketFlag option
   tcp1.Send(sendbuffer, 0, sendbuffer.Length, SocketFlags.OutOfBand);

   byte[] recvbuffer = new byte[sendbuffer.Length];

   // Server will echo the bytes back. Receive the bytes.
   tcp1.Receive(recvbuffer, 0, recvbuffer.Length, SocketFlags.None);

   // Close the connection.
   tcp1.Close();
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace | Tcp.Receive Overload List


Send Method

PowerTCP Telnet for .NET

Tcp.Send Method

Send data to the server.

Overload List

Send data to the server.

public Segment Send(byte[]);

Send data to the server, specifying a buffer, offset, size and SocketFlags value.

public Segment Send(byte[],int,int,SocketFlags);

Send data to the server.

public Segment Send(string);

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.Send Method (Byte[])

Send data to the server.

[Visual Basic]
Overloads Public Function Send( _
ByVal buffer As Byte() _
) As Segment
[C#]
public Segment Send(
byte[] buffer
);

Parameters

buffer
Source memory location for the data to send.

Return Value

A Segment object encapsulating information about the data sent.

Remarks

After connecting, data can be received using the Tcp.Send method. All Tcp.Send methods return a Segment object, encapsulating information about the data sent such as the data sent, and the amount of bytes of data sent.

This method is functionally equivalent to Tcp.Stream.Write(byte[]).

Exceptions

Exception Type | Condition
ArgumentOutOfRangeException | offset or size is less than 0.
ArgumentException | offset + size is greater than the length of buffer.
SocketException | The socket is not connected.

Example

[Visual Basic, C#] The following example demonstrates sending bytes to the server.

[Visual Basic]
Private Sub Test()
   ' Connect to an echo port
   Tcp1.Connect("atropos", 7)

   Dim sendbuffer() As Byte = System.Text.Encoding.Default.GetBytes("abcdefg")

   ' Send some bytes.
   Tcp1.Send(sendbuffer)

   Dim recvbuffer(sendbuffer.Length) As Byte

   ' Server will echo the bytes back. Receive the bytes.
   Tcp1.Receive(recvbuffer)

   ' Close the connection.
   Tcp1.Close()
End Sub
[C#]
private void Test()
{
   // Connect to the echo port
   tcp1.Connect("atropos", 7);

   byte[] sendbuffer = System.Text.Encoding.Default.GetBytes("abcdefg");

   // Send some bytes.
   tcp1.Send(sendbuffer);

   byte[] recvbuffer = new byte[sendbuffer.Length];

   // Server will echo the bytes back. Receive the bytes.
   tcp1.Receive(recvbuffer);

   // Close the connection.
   tcp1.Close();
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace | Tcp.Send Overload List


Tcp.Send Method (Byte[], Int32, Int32, SocketFlags)

Send data to the server, specifying a buffer, offset, size and SocketFlags value.

[Visual Basic]
Overloads Public Function Send( _
ByVal buffer As Byte(), _
ByVal offset As Integer, _
ByVal size As Integer, _
ByVal socketFlags As SocketFlags _
) As Segment
[C#]
public Segment Send(
byte[] buffer,
int offset,
int size,
SocketFlags socketFlags
);

Parameters

buffer
Source memory location for the data to send.
offset
Starting offset within buffer for sending.
size
Number of bytes to send.
socketFlags
A bitwise combination of special use sending parameters.

Return Value

A Segment object encapsulating information about the data sent.

Remarks

After connecting, data can be received using the Tcp.Send method. All Tcp.Send methods return a Segment object, encapsulating information about the data sent such as the data sent, and the amount of bytes of data sent.

This method is the only way to send data to a host while specifying a SocketFlags parameter.

Exceptions

Exception Type | Condition
ArgumentOutOfRangeException | offset or size is less than 0.
ArgumentException | offset + size is greater than the length of buffer.
SocketException | The socket is not connected.

Example

[Visual Basic, C#] The following example demonstrates sending bytes to the server with a SocketFlag option.

[Visual Basic]
Private Sub Test()
   ' Connect to an echo port
   Tcp1.Connect("atropos", 7)

   Dim sendbuffer() As Byte = System.Text.Encoding.Default.GetBytes("abcdefg")

   ' Send some bytes with "OutOfBand" SocketFlag option
   Tcp1.Send(sendbuffer, 0, sendbuffer.Length, SocketFlags.OutOfBand)

   Dim recvbuffer(sendbuffer.Length) As Byte

   ' Server will echo the bytes back. Receive the bytes.
   Tcp1.Receive(recvbuffer, 0, recvbuffer.Length, SocketFlags.None)

   ' Close the connection.
   Tcp1.Close()
End Sub
[C#]
private void Test()
{
   // Connect to the echo port
   tcp1.Connect("atropos", 7);

   byte[] sendbuffer = System.Text.Encoding.Default.GetBytes("abcdefg");

   // Send some bytes with "OutOfBand" SocketFlag option
   tcp1.Send(sendbuffer, 0, sendbuffer.Length, SocketFlags.OutOfBand);

   byte[] recvbuffer = new byte[sendbuffer.Length];

   // Server will echo the bytes back. Receive the bytes.
   tcp1.Receive(recvbuffer, 0, recvbuffer.Length, SocketFlags.None);

   // Close the connection.
   tcp1.Close();
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace | Tcp.Send Overload List


Tcp.Send Method (String)

Send data to the server.

[Visual Basic]
Overloads Public Function Send( _
ByVal buffer As String _
) As Segment
[C#]
public Segment Send(
string buffer
);

Parameters

buffer
Data to be decoded into bytes and sent.

Return Value

A Segment object encapsulating information about the data sent.

Remarks

After connecting, data can be received using the Tcp.Send method. All Tcp.Send methods return a Segment object, encapsulating information about the data sent such as the data sent, and the amount of bytes of data sent.

This method is functionally equivalent to Tcp.Stream.Write.

Exceptions

Exception Type | Condition
ArgumentOutOfRangeException | offset or size is less than 0.
ArgumentException | offset + size is greater than the length of buffer.
SocketException | The socket is not connected.

Example

[Visual Basic, C#] The following example demonstrates connecting implementing the SMTP protocol using the Tcp component to send a simple message.

[Visual Basic]
Private Sub TcpDemo()

   ' The following code assumes that good responses are always received from
   ' the server. More robust code should check each response and handle appropriately.

   ' Connect to SMTP port
   Tcp1.Connect("mail", 25)

   ' Send the EHLO command
   Tcp1.Send("EHLO myserver" + vbCrLf)

   ' Get response from the server
   Dim seg As Segment = Tcp1.Receive()

   ' Send MAIL FROM command
   Tcp1.Send("MAIL FROM: test@myserver.com" + vbCrLf)

   ' Get response from the server
   seg = Tcp1.Receive()

   ' Send RCPT TO command
   Tcp1.Send("RCPT TO: you@yourserver.com" + vbCrLf)

   ' Get response from the server
   seg = Tcp1.Receive()

   ' Send DATA command
   Tcp1.Send("DATA" + vbCrLf)

   ' Get response from the server
   seg = Tcp1.Receive()

   ' Send DATA
   Tcp1.Send("Test Message" + vbCrLf + "." + vbCrLf)

   ' Receive response from the server
   seg = Tcp1.Receive()

   ' Write output
   Debug.WriteLine("Operation complete. The following information")
   Debug.WriteLine("was reported by the server:")
   Debug.WriteLine(seg.ToString())
End Sub
[C#]
private void TcpDemo()
{

   // The following code assumes that good responses are always received from
   // the server. More robust code should check each response and handle appropriately.

   // Connect to SMTP port
   tcp1.Connect("mail", 25);

   // Send the EHLO command
   tcp1.Send("EHLO myserver\r\n");

   // Get response from the server
   Segment seg = tcp1.Receive();

   // Send MAIL FROM command
   tcp1.Send("MAIL FROM: test@myserver.com\r\n");

   // Get response from the server
   seg = tcp1.Receive();

   // Send RCPT TO command
   tcp1.Send("RCPT TO: you@yourserver.com\r\n");

   // Get response from the server
   seg = tcp1.Receive();

   // Send DATA command
   tcp1.Send("DATA\r\n");

   // Get response from the server
   seg = tcp1.Receive();

   // Send DATA
   tcp1.Send("Test Message\r\n.\r\n");

   // Receive response from the server
   seg = tcp1.Receive();

   // Write output
   Debug.WriteLine("Operation complete. The following information");
   Debug.WriteLine("was reported by the server about the operation:");
   Debug.WriteLine(seg.ToString());
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace | Tcp.Send Overload List


Tcp Events

The events of the Tcp class are listed below. For a complete list of Tcp class members, see the Tcp Members topic.

Public Instance Events

ConnectedChanged | Raised when the value of the Object.Connected property changes.
Disposed (inherited from Component) | Adds an event handler to listen to the Disposed event on the component.
EndConnect | Raised when the Tcp.BeginConnect request completes.
EndReceive | Raised when the Tcp.BeginReceive request completes.
EndSend | Raised when the Tcp.BeginSend request completes.
RawTrace | Raised when data has been sent/received.
Trace | Raised when data has been sent/received.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.ConnectedChanged Event

Raised when the value of the Object.Connected property changes.

[Visual Basic]
Public Event ConnectedChanged As EventHandler
[C#]
public event EventHandler ConnectedChanged;

Remarks

This event is raised when the value of the Object.Connected property changes. The value of the Object.Connected property changes whenever a TCP connection to a resource is either made or closed.

This event is useful in several scenarios, for example:

  • Displaying the user when a connection has been terminated.
  • Notifying the application if a connection has been terminated.

If you are using the PowerTCP component as a reference, you must create a method to handle the event yourself. For more information on using events using PowerTCP.NET within the Visual Studio.NET environment, see Using Events In PowerTCP.

Example

[Visual Basic, C#] The following example demonstrates using the ConnectedChanged event to notify the user of the status of the connection.

[Visual Basic]
Private Sub Tcp1_ConnectedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Tcp1.ConnectedChanged
   ' Get current state of connection
   If Tcp1.Connected Then
      Debug.WriteLine("Connection made")

      ' Display info about the local/remote endpoints
      Debug.WriteLine("Local endpoint: " + Tcp1.LocalEndPoint.ToString())
      Debug.WriteLine("Remote endpoint: " + Tcp1.RemoteEndPoint.ToString())
   Else
      Debug.WriteLine("Connection closed")
   End If
End Sub
[C#]
private void tcp1_ConnectedChanged(object sender, System.EventArgs e)
{
    // Get current state of connection
    if(tcp1.Connected)
    {
        Debug.WriteLine("Connection made");

        // Display info about the local/remote endpoints
        Debug.WriteLine("Local endpoint: " + tcp1.LocalEndPoint.ToString());
        Debug.WriteLine("Remote endpoint: " + tcp1.RemoteEndPoint.ToString());
    }
    else
        Debug.WriteLine("Connection closed");
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.EndConnect Event

Raised when the Tcp.BeginConnect request completes.

[Visual Basic]
Public Event EndConnect As ConnectEventHandler
[C#]
public event ConnectEventHandler EndConnect;

Event Data

The event handler receives an argument of type ExceptionEventArgs containing data related to this event. The following ExceptionEventArgs properties provide information specific to this event.

Property | Description
Exception | Gets any exception which occurred during the asynchronous operation.
State | Gets the object that was included as part of the associated method call.

Remarks

This event is raised when the asynchronous method call Tcp.BeginConnect completes. An EventArgs object is passed into the event, containing information about the event.

For more information on using events using PowerTCP.NET within the Visual Studio.NET environment, see the topic, Using Events In PowerTCP.

If you are using the Tcp component as a reference, you must create a method to handle the event yourself.

This event MUST be implemented if you are using the Tcp.BeginConnect method.

Example

[Visual Basic, C#] The following example demonstrates asynchronously connecting using the BeginConnect method.

[Visual Basic]
Private Sub Test()
   ' Begin to asynchronously connect to an echo port.
   Tcp1.BeginConnect("atropos", 7)
End Sub

Private Sub Tcp1_EndConnect(ByVal sender As Object, ByVal e As Dart.PowerTCP.SecureFtp.ExceptionEventArgs) Handles Tcp1.EndConnect
   ' Connect complete, check for any exceptions
   If e.Exception Is Nothing Then
      ' Now send some data.
      Tcp1.Send("hello")

      ' Receive the data back.
      Dim seg As Segment = Tcp1.Receive()
      Debug.WriteLine(seg.ToString())
   End If
End Sub
[C#]
private void Test()
{
   // Begin to asynchronously connect to an echo port.
   tcp1.BeginConnect("atropos", 7);
}

private void tcp1_EndConnect(object sender, Dart.PowerTCP.SecureFtp.ExceptionEventArgs e)
{
   // Connect complete, check for any exceptions
   if(e.Exception == null)
   {
      // Now send some data.
      tcp1.Send("hello");

      // Receive the data back.
      Segment seg = tcp1.Receive();

      Debug.WriteLine(seg.ToString());
   }
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.EndReceive Event

Raised when the Tcp.BeginReceive request completes.

[Visual Basic]
Public Event EndReceive As SegmentEventHandler
[C#]
public event SegmentEventHandler EndReceive;

Event Data

The event handler receives an argument of type SegmentEventArgs containing data related to this event. The following SegmentEventArgs properties provide information specific to this event.

Property | Description
Exception | Gets any exception which occurred during the asynchronous operation.
Segment | The Segment object referencing the data that was sent or received.
State | Gets the object that was included as part of the associated method call.

Remarks

This event is raised when the asynchronous method call Tcp.BeginReceive completes. A SegmentEventArgs object is passed into the event, containing information about the event, such as the data received.

If any errors occurred during the asynchronous operation, they would be returned in the SegmentEventArgs object, check SegmentEventArgs.Exception to check for any exception.

For more information on using events using PowerTCP.NET within the Visual Studio.NET environment, see the topic, Using Events In PowerTCP.

If you are using the Tcp component as a reference, you must create a method to handle the event yourself.

This event MUST be implemented if you are using the Tcp.BeginReceive method.

Example

[Visual Basic, C#] The following example demonstrates asynchronous receiving and sending of data.

[Visual Basic]
Private Sub AsynchTcpDemo()

   ' Attempt to connect to an echo port.
   Try
      Tcp1.Connect("myserver", 7)
   Catch ex As Exception
      Return
   End Try

   ' Send data, since we are connected to an echo port, the same data should be returned.
   ' The following code demonstrates asynchronously sending data. When data has been sent
   ' the EndSend event will be raised.

   Dim buffer() As Byte = System.Text.Encoding.Default.GetBytes("a")
   Tcp1.BeginSend(buffer, 0, buffer.Length, Net.Sockets.SocketFlags.None, Nothing)
End Sub

Private Sub Tcp1_EndSend(ByVal sender As Object, ByVal e As Dart.PowerTCP.SegmentEventArgs) Handles Tcp1.EndSend
   ' Check for exception
   If e.Exception Is Nothing Then

      ' Send is complete. Display info about the data sent.
      Debug.WriteLine("Byte count sent: " + e.Segment.Count)
      Debug.WriteLine("Data sent: " + e.Segment.ToString())

      Dim buffer(Tcp1.ReceiveBufferSize) As Byte

      ' Receive the data. The EndReceive event will be raised upon completion.
      Tcp1.BeginReceive(buffer, 0, buffer.Length, Net.Sockets.SocketFlags.None, Nothing)

    End If
End Sub

Private Sub Tcp1_EndReceive(ByVal sender As Object, ByVal e As Dart.PowerTCP.SegmentEventArgs) Handles Tcp1.EndReceive
   ' Check for exception
   If e.Exception Is Nothing Then

      ' Receive is complete. Display info about the data sent.
      Debug.WriteLine("Byte count received: " + e.Segment.Count)
      Debug.WriteLine("Data received: " + e.Segment.ToString())

      ' Close the connection
      Tcp1.Close()
    End If
End Sub
[C#]
private void AsynchTcpDemo()
{
    // Attempt to connect to an echo port.
    try
    {
        tcp1.Connect("myserver", 7);
    }
    catch(Exception ex)
    {return;}

    // Send data, since we are connected to an echo port, the same data should be returned.
    // The following code demonstrates asynchronously sending data. When data has been sent
    // the EndSend event will be raised.

    byte[] buffer = System.Text.Encoding.Default.GetBytes("a");
    tcp1.BeginSend(buffer, 0, buffer.Length, System.Net.Sockets.SocketFlags.None, null);
}

private void tcp1_EndSend(object sender, Dart.PowerTCP.SegmentEventArgs e)
{
    // Check for exception
    if(e.Exception == null)
    {
        // Send is complete. Display info about the data sent.
        Debug.WriteLine("Byte count sent: " + e.Segment.Count);
        Debug.WriteLine("Data sent: " + e.Segment.ToString());

        byte[] buffer = new byte[tcp1.ReceiveBufferSize];

        // Receive the data. The EndReceive event will be raised upon completion.
        tcp1.BeginReceive(buffer, 0, buffer.Length, System.Net.Sockets.SocketFlags.None, null);
    }
}

private void tcp1_EndReceive(object sender, Dart.PowerTCP.SegmentEventArgs e)
{
    // Check for exception
    if(e.Exception == null)
    {
        // Receive is complete. Display info about the data sent.
        Debug.WriteLine("Byte count received: " + e.Segment.Count);
        Debug.WriteLine("Data received: " + e.Segment.ToString());

        // Close the connection
        tcp1.Close();
    }
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.EndSend Event

Raised when the Tcp.BeginSend request completes.

[Visual Basic]
Public Event EndSend As SegmentEventHandler
[C#]
public event SegmentEventHandler EndSend;

Event Data

The event handler receives an argument of type SegmentEventArgs containing data related to this event. The following SegmentEventArgs properties provide information specific to this event.

Property | Description
Exception | Gets any exception which occurred during the asynchronous operation.
Segment | The Segment object referencing the data that was sent or received.
State | Gets the object that was included as part of the associated method call.

Remarks

This event is raised when the asynchronous method call Tcp.BeginSend completes. A SegmentEventArgs object is passed into the event, containing information about the event, such as the data sent.

If any errors occurred during the asynchronous operation, they would be returned in the SegmentEventArgs object, check SegmentEventArgs.Exception to check for any exception.

For more information on using events using PowerTCP.NET within the Visual Studio.NET environment, see the topic, Using Events In PowerTCP.

If you are using the Tcp component as a reference, you must create a method to handle the event yourself.

This event MUST be implemented if you are using the Tcp.BeginSend method.

Example

[Visual Basic, C#] The following example demonstrates asynchronous receiving and sending of data.

[Visual Basic]
Private Sub AsynchTcpDemo()

   ' Attempt to connect to an echo port.
   Try
      Tcp1.Connect("myserver", 7)
   Catch ex As Exception
      Return
   End Try

   ' Send data, since we are connected to an echo port, the same data should be returned.
   ' The following code demonstrates asynchronously sending data. When data has been sent
   ' the EndSend event will be raised.

   Dim buffer() As Byte = System.Text.Encoding.Default.GetBytes("a")
   Tcp1.BeginSend(buffer, 0, buffer.Length, Net.Sockets.SocketFlags.None, Nothing)
End Sub

Private Sub Tcp1_EndSend(ByVal sender As Object, ByVal e As Dart.PowerTCP.SegmentEventArgs) Handles Tcp1.EndSend
   ' Check for exception
   If e.Exception Is Nothing Then

      ' Send is complete. Display info about the data sent.
      Debug.WriteLine("Byte count sent: " + e.Segment.Count)
      Debug.WriteLine("Data sent: " + e.Segment.ToString())

      Dim buffer(Tcp1.ReceiveBufferSize) As Byte

      ' Receive the data. The EndReceive event will be raised upon completion.
      Tcp1.BeginReceive(buffer, 0, buffer.Length, Net.Sockets.SocketFlags.None, Nothing)

    End If
End Sub

Private Sub Tcp1_EndReceive(ByVal sender As Object, ByVal e As Dart.PowerTCP.SegmentEventArgs) Handles Tcp1.EndReceive
   ' Check for exception
   If e.Exception Is Nothing Then

      ' Receive is complete. Display info about the data sent.
      Debug.WriteLine("Byte count received: " + e.Segment.Count)
      Debug.WriteLine("Data received: " + e.Segment.ToString())

      ' Close the connection
      Tcp1.Close()
    End If
End Sub
[C#]
private void AsynchTcpDemo()
{
    // Attempt to connect to an echo port.
    try
    {
        tcp1.Connect("myserver", 7);
    }
    catch(Exception ex)
    {return;}

    // Send data, since we are connected to an echo port, the same data should be returned.
    // The following code demonstrates asynchronously sending data. When data has been sent
    // the EndSend event will be raised.

    byte[] buffer = System.Text.Encoding.Default.GetBytes("a");
    tcp1.BeginSend(buffer, 0, buffer.Length, System.Net.Sockets.SocketFlags.None, null);
}

private void tcp1_EndSend(object sender, Dart.PowerTCP.SegmentEventArgs e)
{
    // Check for exception
    if(e.Exception == null)
    {
        // Send is complete. Display info about the data sent.
        Debug.WriteLine("Byte count sent: " + e.Segment.Count);
        Debug.WriteLine("Data sent: " + e.Segment.ToString());

        byte[] buffer = new byte[tcp1.ReceiveBufferSize];

        // Receive the data. The EndReceive event will be raised upon completion.
        tcp1.BeginReceive(buffer, 0, buffer.Length, System.Net.Sockets.SocketFlags.None, null);
    }
}

private void tcp1_EndReceive(object sender, Dart.PowerTCP.SegmentEventArgs e)
{
    // Check for exception
    if(e.Exception == null)
    {
        // Receive is complete. Display info about the data sent.
        Debug.WriteLine("Byte count received: " + e.Segment.Count);
        Debug.WriteLine("Data received: " + e.Segment.ToString());

        // Close the connection
        tcp1.Close();
    }
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.RawTrace Event

Raised when data has been sent/received.

[Visual Basic]
Public Event RawTrace As SegmentEventHandler
[C#]
public event SegmentEventHandler RawTrace;

Event Data

The event handler receives an argument of type SegmentEventArgs containing data related to this event. The following SegmentEventArgs properties provide information specific to this event.

Property | Description
Exception | Gets any exception which occurred during the asynchronous operation.
Segment | The Segment object referencing the data that was sent or received.
State | Gets the object that was included as part of the associated method call.

Remarks

Use this event for advanced runtime debugging for security implementations. For general data traces use the Object.Trace event.

The Object.RawTrace event always reports actual data sent/received over the socket. The Count of each segment reflects the number of bytes actually written and received. The Object.Trace event reports data sent/received at a higher level. For example, for the Telnet component, Object.Trace reports data sent/received, but does not report IAC option sequences that are processed by TelnetStream, whereas Object.RawTrace allows you to trace the actual data sent/received, including Telnet option commands.

If you are using the PowerTCP component as a reference, you must create a method to handle the event yourself. For more information on using events using PowerTCP.NET within the Visual Studio.NET environment, see Using Events In PowerTCP.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


Tcp.Trace Event

Raised when data has been sent/received.

[Visual Basic]
Public Event Trace As SegmentEventHandler
[C#]
public event SegmentEventHandler Trace;

Event Data

The event handler receives an argument of type SegmentEventArgs containing data related to this event. The following SegmentEventArgs properties provide information specific to this event.

Property | Description
Exception | Gets any exception which occurred during the asynchronous operation.
Segment | The Segment object referencing the data that was sent or received.
State | Gets the object that was included as part of the associated method call.

Remarks

This event is raised when commands or data has been sent/received. If you are using a component which uses TCP as the transport protocol a SegmentEventArgs object is passed into the event containing any commands or data sent or received. If you are using a component which uses UDP as the transport protocol a DatagramEventArgs object is passed into the event containing any commands or data sent or received.

The Object.RawTrace event always reports actual data sent/received over the socket. The Count of each segment reflects the number of bytes actually written and received. The Object.Trace event reports data sent/received at a higher level. For example, for the Telnet component, Object.Trace reports data sent/received, but does not report IAC option sequences that are processed by TelnetStream, whereas Object.RawTrace allows you to trace the actual data sent/received, including Telnet option commands.

If you are using the PowerTCP component as a reference, you must create a method to handle the event yourself. For more information on using events using PowerTCP.NET within the Visual Studio.NET environment, see Using Events In PowerTCP.

Example

[Visual Basic, C#] The following example demonstrates using the Tcp component's Trace event to create a log of all data sent and received.

[Visual Basic]
Private Sub Tcp1_Trace(ByVal sender As Object, ByVal e As Dart.PowerTCP.SecureFtp.SegmentEventArgs) Handles Tcp1.Trace
   ' Get the data into a byte array
   Dim buffer As Byte() = System.Text.Encoding.Default.GetBytes(e.Segment.ToString())

   ' Create a FileStream
   Dim f As New FileStream("C:\test\socketlog.log", FileMode.Append)

   ' Write the data to the file.
   f.Write(buffer, 0, buffer.Length)
   f.Close()
End Sub
[C#]
private void tcp1_Trace(object sender, Dart.PowerTCP.SecureFtp.SegmentEventArgs e)
{
   // Get the data into a byte array
   byte[] buffer = System.Text.Encoding.Default.GetBytes(e.Segment.ToString());

   // Create a FileStream
   FileStream f = new FileStream("C:\\test\\socketlog.txt", FileMode.Append);

   // Write the data to the file.
   f.Write(buffer, 0, buffer.Length);
   f.Close();
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


TcpStream Class

TcpStream implements sending and receiving of data through network sockets.

For a list of all members of this type, see TcpStream Members.

System.Object
MarshalByRefObject
Stream
EnhancedStream
TcpStream

[Visual Basic]
Public Class TcpStream
Inherits EnhancedStream
[C#]
public class TcpStream : EnhancedStream

Remarks

All PowerTCP components which use TCP as the transport-layer protocol use this class as the interface to the Socket.

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

TcpStream Members | Dart.PowerTCP.Telnet Namespace


TcpStream Members

TcpStream overview

Public Instance Constructors

TcpStream Constructor Initializes a new instance of the TcpStream class for the specified Tcp object.

Public Instance Properties

Available | Gets the amount of data that has been received from the network and is available to be read.
CanRead | Indicates that data can be read from the stream.
CanSeek (inherited from EnhancedStream) | Gets a value indicating whether the current stream supports seeking.
CanWrite | Indicates that data can be written to the stream.
Charset (inherited from EnhancedStream) | Gets and sets the character set used for string/byte array conversions.
Encoding (inherited from EnhancedStream) | Gets or sets the type of encoding to use.
Length (inherited from EnhancedStream) | The length of data available on the stream. This method always throws a NotSupportedException.
Position (inherited from EnhancedStream) | Gets or sets the position in the stream. This method always throws a NotSupportedException.

Public Instance Methods

BeginRead (inherited from Stream) | Begins an asynchronous read operation.
BeginWrite (inherited from Stream) | Begins an asynchronous write operation.
Close | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from EnhancedStream) | Overloaded. Releases all resources associated with the object.
EndRead (inherited from Stream) | Waits for the pending asynchronous read to complete.
EndWrite (inherited from Stream) | Ends an asynchronous write operation.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Flush (inherited from EnhancedStream) | Default implementation is no-op. May be overriden by derived classes
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Read | Overloaded. Reads at least one byte of data from the stream and copies it into the provided buffer.
Read (inherited from EnhancedStream) | Overloaded. When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
ReadByte (inherited from Stream) | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
Save (inherited from EnhancedStream) | Overloaded. Saves the data in the stream to the file specified by fileName.
Seek (inherited from EnhancedStream) | Sets the position within the current Stream to the specified value. Always throws a NotSupportedException.
SetLength (inherited from EnhancedStream) | Sets the length of the current Stream to the specified value. Always throws a NotSupportedException.
ToArray (inherited from EnhancedStream) | Returns the byte array representation of the Stream data.
ToString (inherited from EnhancedStream) | Returns the string representation of the Stream data.
Write | Overloaded. Writes a sequence of bytes to the stream and returns when the operation is complete.
Write (inherited from EnhancedStream) | Overloaded. When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
WriteByte (inherited from Stream) | Writes a byte to the current position in the stream and advances the position within the stream by one byte.
WriteTo (inherited from EnhancedStream) | Overloaded. Writes all of the data contained in this Stream to a destination Stream.

Explicit Interface Implementations

IDisposable.Dispose (inherited from Stream)

See Also

TcpStream Class | Dart.PowerTCP.Telnet Namespace


TcpStream Constructor

Initializes a new instance of the TcpStream class for the specified Tcp object.

[Visual Basic]
Public Sub New( _
ByVal tcp As Tcp _
)
[C#]
public TcpStream(
Tcp tcp
);

Parameters

tcp
The Tcp object that provides the network data for the new TcpStream.

See Also

TcpStream Class | Dart.PowerTCP.Telnet Namespace


TcpStream Properties

The properties of the TcpStream class are listed below. For a complete list of TcpStream class members, see the TcpStream Members topic.

Public Instance Properties

Available | Gets the amount of data that has been received from the network and is available to be read.
CanRead | Indicates that data can be read from the stream.
CanSeek (inherited from EnhancedStream) | Gets a value indicating whether the current stream supports seeking.
CanWrite | Indicates that data can be written to the stream.
Charset (inherited from EnhancedStream) | Gets and sets the character set used for string/byte array conversions.
Encoding (inherited from EnhancedStream) | Gets or sets the type of encoding to use.
Length (inherited from EnhancedStream) | The length of data available on the stream. This method always throws a NotSupportedException.
Position (inherited from EnhancedStream) | Gets or sets the position in the stream. This method always throws a NotSupportedException.

See Also

TcpStream Class | Dart.PowerTCP.Telnet Namespace


TcpStream.Available Property

Gets the amount of data that has been received from the network and is available to be read.

[Visual Basic]
Overridable Public ReadOnly Property Available As Integer
[C#]
public virtual int Available {get;}

See Also

TcpStream Class | Dart.PowerTCP.Telnet Namespace


TcpStream.CanRead Property

Indicates that data can be read from the stream.

[Visual Basic]
Overrides Public ReadOnly Property CanRead As Boolean
[C#]
public override bool CanRead {get;}

Remarks

If the stream is closed, this property returns false.

See Also

TcpStream Class | Dart.PowerTCP.Telnet Namespace


TcpStream.CanWrite Property

Indicates that data can be written to the stream.

[Visual Basic]
Overrides Public ReadOnly Property CanWrite As Boolean
[C#]
public override bool CanWrite {get;}

Remarks

If the stream is closed, this property returns false.

See Also

TcpStream Class | Dart.PowerTCP.Telnet Namespace


TcpStream Methods

The methods of the TcpStream class are listed below. For a complete list of TcpStream class members, see the TcpStream Members topic.

Public Instance Methods

BeginRead (inherited from Stream) | Begins an asynchronous read operation.
BeginWrite (inherited from Stream) | Begins an asynchronous write operation.
Close | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from EnhancedStream) | Overloaded. Releases all resources associated with the object.
EndRead (inherited from Stream) | Waits for the pending asynchronous read to complete.
EndWrite (inherited from Stream) | Ends an asynchronous write operation.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Flush (inherited from EnhancedStream) | Default implementation is no-op. May be overriden by derived classes
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Read | Overloaded. Reads at least one byte of data from the stream and copies it into the provided buffer.
Read (inherited from EnhancedStream) | Overloaded. When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
ReadByte (inherited from Stream) | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
Save (inherited from EnhancedStream) | Overloaded. Saves the data in the stream to the file specified by fileName.
Seek (inherited from EnhancedStream) | Sets the position within the current Stream to the specified value. Always throws a NotSupportedException.
SetLength (inherited from EnhancedStream) | Sets the length of the current Stream to the specified value. Always throws a NotSupportedException.
ToArray (inherited from EnhancedStream) | Returns the byte array representation of the Stream data.
ToString (inherited from EnhancedStream) | Returns the string representation of the Stream data.
Write | Overloaded. Writes a sequence of bytes to the stream and returns when the operation is complete.
Write (inherited from EnhancedStream) | Overloaded. When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
WriteByte (inherited from Stream) | Writes a byte to the current position in the stream and advances the position within the stream by one byte.
WriteTo (inherited from EnhancedStream) | Overloaded. Writes all of the data contained in this Stream to a destination Stream.

Explicit Interface Implementations

IDisposable.Dispose (inherited from Stream)

See Also

TcpStream Class | Dart.PowerTCP.Telnet Namespace


TcpStream.Close Method

Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream.

[Visual Basic]
Overrides Public Sub Close()
[C#]
public override void Close();

See Also

TcpStream Class | Dart.PowerTCP.Telnet Namespace


Read Method

PowerTCP Telnet for .NET

TcpStream.Read Method

Reads at least one byte of data from the stream and copies it into the provided buffer.

Overload List

Inherited from EnhancedStream.

public int Read(byte[]);

Reads at least one byte of data from the stream and copies it into the provided buffer.

public override int Read(byte[],int,int);

See Also

TcpStream Class | Dart.PowerTCP.Telnet Namespace


TcpStream.Read Method (Byte[], Int32, Int32)

Reads at least one byte of data from the stream and copies it into the provided buffer.

[Visual Basic]
Overrides Overloads Public Function Read( _
ByVal buffer As Byte(), _
ByVal offset As Integer, _
ByVal size As Integer _
) As Integer
[C#]
public override int Read(
byte[] buffer,
int offset,
int size
);

Parameters

buffer
The storage location for the received data.
offset
The zero-based position in the buffer at which to store the received data.
size
The maximum number of bytes to read.

Return Value

The total number of bytes read into the buffer.

Remarks

This is the standard method to use when reading a stream synchronously.

The return value may be less than the number of bytes requested if that many bytes are not currently available, or zero if the end of the stream has been reached. Applications must check this value to know how many bytes were read into the buffer.

Exceptions

Exception Type | Condition
IOException | Thrown when the stream is not Readable.
ArgumentNullException | Thrown when the receiving buffer is null.
ArgumentOutOfRangeException | Thrown when the offset is less than zero or when size is less than or equal to zero.
ArgumentException | Thrown when the (offset + size) > buffer.Length.

See Also

TcpStream Class | Dart.PowerTCP.Telnet Namespace | TcpStream.Read Overload List


Write Method

PowerTCP Telnet for .NET

TcpStream.Write Method

Writes a sequence of bytes to the stream and returns when the operation is complete.

Overload List

Inherited from EnhancedStream.

public void Write(byte[]);

Writes a sequence of bytes to the stream and returns when the operation is complete.

public override void Write(byte[],int,int);

See Also

TcpStream Class | Dart.PowerTCP.Telnet Namespace


TcpStream.Write Method (Byte[], Int32, Int32)

Writes a sequence of bytes to the stream and returns when the operation is complete.

[Visual Basic]
Overrides Overloads Public Sub Write( _
ByVal buffer As Byte(), _
ByVal offset As Integer, _
ByVal size As Integer _
)
[C#]
public override void Write(
byte[] buffer,
int offset,
int size
);

Parameters

buffer
The storage location of the data to be sent.
offset
The zero-based position in the buffer from which to begin writing from.
size
The exact number of bytes to write.

Remarks

Use the CanWrite property to determine whether the current instance supports writing.

Exceptions

Exception Type | Condition
IOException | Thrown when the stream is not Writeable.
ArgumentNullException | Thrown when buffer is null.
ArgumentOutOfRangeException | Thrown when the offset is less than zero or when size is less than or equal to zero.
ArgumentException | Thrown when the (offset + size) > buffer.Length.

See Also

TcpStream Class | Dart.PowerTCP.Telnet Namespace | TcpStream.Write Overload List


Telnet Class

Integrates Telnet communications into any .NET application.

For a list of all members of this type, see Telnet Members.

System.Object
MarshalByRefObject
Component
Tcp
Telnet

[Visual Basic]
Public Class Telnet
Inherits Tcp
[C#]
public class Telnet : Tcp

Remarks

Use the Telnet Component to establish and manage Telnet-level streams of data. It simplifies the use of Telnet communications by providing methods to establish connections, send and receive data, and to terminate connections. Synchronous and asynchronous use is fully supported.

Using the Telnet Component

What follows are short usage descriptions. For more information, see the appropriate member topic.

Connecting: To connect to a host, use either Telnet.Connect (to connect synchronously) or Telnet.BeginConnect (to connect asynchronously), specifying a remote host to connect to.

Sending data: After connecting, send data by using either Telnet.Send (to send data synchronously) or Telnet.BeginSend (to send data asynchronously). These methods are overloaded to allow sending of strings or byte arrays. A Segment object is returned from all Send operations, containing information about the data sent. In addition, you can use Telnet.Stream.Write to gain advanced capabilities when sending data.

Receiving data: To receive data, use either Telnet.Receive (to receive data synchronously) or Telnet.BeginReceive (to receive data asynchronously). This method is most useful when you want to receive all available data in the buffer. In addition, you can use Telnet.Stream.Read to gain advanced capabilities when receiving data.

Default option negotiation: To make option negotiation as simple as possible, the Telnet component uses a default option negotion sequence which occurs automatically after login.

Customized option negotiation: The option negotiation can also be customized to be as flexible as you need. Simple add an Option object representing the option you would like to modify to the Telnet.ClientOptions or Telnet.ServerOptions collection and the Telnet component will attempt to negotiate the option.

Sending commands: Use the Telnet.SendCommand method to send any control command to the host.

Automatic login: Use the Telnet.Login method to automatically login to the host, issuing the specified username and password.

Example

[Visual Basic, C#] The following example demonstrates basic Telnet usage.

[Visual Basic]
' Set ReceiveTimeout to nonzero, required for Login method
Telnet1.ReceiveTimeout = 3000

' Login
Telnet1.Login("myserver", "myuser", "mypass", "$ ")

' Send a command
Telnet1.Send("pwd" + vbCrLf)

' Receive the response
Dim Seg As Segment = Telnet1.Receive()
Debug.WriteLine(Seg.ToString())

' Close the connection
Telnet1.Close()
[C#]
// Set ReceiveTimeout to nonzero, required for Login method
telnet1.ReceiveTimeout = 3000;

// Login
telnet1.Login("myserver", "myuser", "mypass", "$ ");

// Send a command
telnet1.Send("pwd\r\n");

// Receive the response
Segment seg = telnet1.Receive();
Debug.WriteLine(seg.ToString());

// Close the connection
telnet1.Close();

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

Telnet Members | Dart.PowerTCP.Telnet Namespace


Telnet Members

Telnet overview

Public Instance Constructors

Telnet Overloaded. Initializes a new instance of the Telnet class.

Public Instance Properties

AutoReceive (inherited from Tcp) | Gets or sets a value which determines if data is automatically receved.
Available (inherited from Tcp) | Gets the amount of data that has been received from the network and is available to be read.
Binary | Gets or sets a value which indicates if the TRANSMIT-BINARY option should be negotiated for both client and server.
Charset (inherited from Tcp) | Gets and sets the character set used for string/byte array conversions.
ClientOptions | Contains the current client options for a Telnet session.
Connected (inherited from Tcp) | Gets the connected state of the connection.
ConnectTimeout (inherited from Tcp) | Gets or sets the number of milliseconds to wait for response from the server when connecting.
Container (inherited from Component) | Gets the IContainer that contains the Component.
DoEvents (inherited from Tcp) | Gets or sets a value that controls the processing of events during blocking method calls.
Echo | Gets or sets a value which inidicates that the ECHO option should be negotiated.
Editor | In Visual Studio.NET, displays an interactive form to use to test real time protocol operations.
KeepAlive (inherited from Tcp) | Gets or sets the value of the socket's KeepAlive option.
LocalEndPoint (inherited from Tcp) | Returns the local address the socket is bound to.
NoDelay (inherited from Tcp) | Gets and sets a value the disables the use of Nagle's algorithm so that data is sent immediately.
OutOfBandInline (inherited from Tcp) | Gets or sets a value that indicates whether out-of-band (urgent) data is read as normal in-line data.
Proxy (inherited from Tcp) | Returns the Proxy instance that controls proxy server use.
ReceiveBufferSize (inherited from Tcp) | Gets and sets the size of the system receive buffer.
ReceiveTimeout (inherited from Tcp) | Gets and sets the number of milliseconds that a Tcp.Receive method will block before throwing a SocketException.
RemoteEndPoint (inherited from Tcp) | Returns the remote address/port the socket is connected to.
ReuseAddress (inherited from Tcp) | Gets or sets a value that typically allows any local port to be specified, even if it is already in use.
SendBufferSize (inherited from Tcp) | Gets and sets the size of the system send buffer.
SendTimeout (inherited from Tcp) | Gets and sets the number of milliseconds that a Tcp.Send method will block before throwing a SocketException.
ServerOptions | Contains the current server options for a Telnet session.
Site (inherited from Component) | Gets or sets the ISite of the Component.
Socket (inherited from Tcp) | Returns a reference to the System.Net.Sockets.Socket instance being used.
Stream (inherited from Tcp) | Returns a SegmentedStream that can be used for advanced streaming operations on the socket.
SynchronizingObject (inherited from Tcp) | Set this object to automatically control thread marshalling between worker threads and the main UI thread.
Tag (inherited from Tcp) | Gets or sets an object reference that can be used to associate this instance with any other.
TerminalType | Gets or sets a value representing the client's terminal type.
WindowSize | Gets or sets a value representing the client's window size.

Public Instance Methods

BeginConnect (inherited from Tcp) | Overloaded. Connect to a server asynchronously, specifying the local interface and a range of local ports to use. The Tcp.EndConnect event is raised when completed.
BeginConnect | Overloaded. Connect to a server asynchronously. The Telnet.EndConnect event is raised when completed.
BeginReceive (inherited from Tcp) | Overloaded. Receive data into your buffer asynchronously specifying a buffer, offset, size and SocketFlags value. The Tcp.EndReceive event is raised when completed.
BeginSend (inherited from Tcp) | Overloaded. Send data from your buffer asynchronously, specifying a buffer, offset, size and SocketFlags value. The Tcp.EndSend event is raised when completed.
Close (inherited from Tcp) | Overloaded. Close the connection.
Connect (inherited from Tcp) | Overloaded. Connect to a host, specifying the local interface and a range of local ports to use.
Connect | Overloaded. Connect to a host.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from Component) | Releases all resources used by the Component.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Login | Connects to a Telnet server and attempts to automatically login.
Receive (inherited from Tcp) | Overloaded. Receive data from the host, specifying a buffer, offset, size and SocketFlags value.
Refresh | Performs option negotiation for any option that has not yet been sent.
Send (inherited from Tcp) | Overloaded. Send data to the server, specifying a buffer, offset, size and SocketFlags value.
SendCommand | Send a Telnet control function.
SendOption | Send option data to the remote host.
SendSubOption | Send suboption data to the remote host.
ToString (inherited from Component) |
WaitFor | Reads data from the stream until the specified string is found.

Public Instance Events

ClientOptionChanged | Raised when a client Telnet option has changed state (WILL or WONT confirmed).
CommandReceived | This event is raised when a Telnet command has been received from the server.
ConnectedChanged (inherited from Tcp) | Raised when the value of the Object.Connected property changes.
Disposed (inherited from Component) | Adds an event handler to listen to the Disposed event on the component.
EndConnect (inherited from Tcp) | Raised when the Tcp.BeginConnect request completes.
EndReceive (inherited from Tcp) | Raised when the Tcp.BeginReceive request completes.
EndSend (inherited from Tcp) | Raised when the Tcp.BeginSend request completes.
RawTrace (inherited from Tcp) | Raised when data has been sent/received.
ServerOptionChanged | Raised when a server Telnet option has changed state (DO or DONT confirmed).
Trace (inherited from Tcp) | Raised when data has been sent/received.

See Also

Telnet Class | Dart.PowerTCP.Telnet Namespace


Telnet Constructor

Initializes a new instance of the Telnet component.

Overload List

Initializes a new instance of the Telnet component.

public Telnet();

Initializes a new instance of the Telnet component.

public Telnet(IContainer);

See Also

Telnet Class | Dart.PowerTCP.Telnet Namespace


Telnet Constructor (IContainer)

Initializes a new instance of the Telnet component.

[Visual Basic]
Overloads Public Sub New( _
ByVal container As IContainer _
)
[C#]
public Telnet(
IContainer container
);

Parameters

container
The IContainer which contains the object.

Remarks

This constructor initializes a new instance of the Telnet component, adding it to the specified IContainer container.

To create an instance of the Telnet component using Visual Studio.NET, simply add the Telnet component to the form and the object will automatically be created and initialized. If working out of the Visual Studio.NET environment (or using the Telnet component as a reference), the Telnet component will have to be explicitly created and initialized.

The following table shows initial property values for an instance of Telnet.

Property | Initial Value
Telnet.Binary | OptionState.Off
Telnet.Charset | Default system charset (accessible via System.Text.Encoding.Default.BodyName)
Telnet.ClientOptions | Options collection
Telnet.DoEvents | true
Telnet.Echo | OptionState.Off
Telnet.KeepAlive | false
Telnet.NoDelay | false
Telnet.OutOfBandInline | false
Telnet.ReceiveBufferSize | 8192
Telnet.ReceiveTimeout | 0
Telnet.ReuseAddress | false
Telnet.SendBufferSize | 8192
Telnet.SendTimeout | 0
Telnet.ServerOptions | Options collection
Telnet.TerminalType | tty
Telnet.WindowSize | System.Drawing.Size (80,24)

See Also

Telnet Class | Dart.PowerTCP.Telnet Namespace | Telnet Constructor Overload List


Telnet Constructor ()

Initializes a new instance of the Telnet component.

[Visual Basic]
Overloads Public Sub New()
[C#]
public Telnet();

Remarks

The default constructor initializes a new instance of the Telnet component.

To create an instance of the Telnet component using Visual Studio.NET, simply add the Telnet component to the form and the object will automatically be created and initialized. If working out of the Visual Studio.NET environment (or using the Telnet component as a reference), the Telnet component will have to be explicitly created and initialized.

The following table shows initial property values for an instance of Telnet.

Property | Initial Value
Telnet.Binary | OptionState.Off
Telnet.Charset | Default system charset (accessible via System.Text.Encoding.Default.BodyName)
Telnet.ClientOptions | Options collection
Telnet.DoEvents | true
Telnet.Echo | OptionState.Off
Telnet.KeepAlive | false
Telnet.NoDelay | false
Telnet.OutOfBandInline | false
Telnet.ReceiveBufferSize | 8192
Telnet.ReceiveTimeout | 0
Telnet.ReuseAddress | false
Telnet.SendBufferSize | 8192
Telnet.SendTimeout | 0
Telnet.ServerOptions | Options collection
Telnet.TerminalType | tty
Telnet.WindowSize | System.Drawing.Size (80,24)

See Also

Telnet Class | Dart.PowerTCP.Telnet Namespace | Telnet Constructor Overload List


Telnet Properties

The properties of the Telnet class are listed below. For a complete list of Telnet class members, see the Telnet Members topic.

Public Instance Properties

AutoReceive (inherited from Tcp) | Gets or sets a value which determines if data is automatically receved.
Available (inherited from Tcp) | Gets the amount of data that has been received from the network and is available to be read.
Binary | Gets or sets a value which indicates if the TRANSMIT-BINARY option should be negotiated for both client and server.
Charset (inherited from Tcp) | Gets and sets the character set used for string/byte array conversions.
ClientOptions | Contains the current client options for a Telnet session.
Connected (inherited from Tcp) | Gets the connected state of the connection.
ConnectTimeout (inherited from Tcp) | Gets or sets the number of milliseconds to wait for response from the server when connecting.
Container (inherited from Component) | Gets the IContainer that contains the Component.
DoEvents (inherited from Tcp) | Gets or sets a value that controls the processing of events during blocking method calls.
Echo | Gets or sets a value which inidicates that the ECHO option should be negotiated.
Editor | In Visual Studio.NET, displays an interactive form to use to test real time protocol operations.
KeepAlive (inherited from Tcp) | Gets or sets the value of the socket's KeepAlive option.
LocalEndPoint (inherited from Tcp) | Returns the local address the socket is bound to.
NoDelay (inherited from Tcp) | Gets and sets a value the disables the use of Nagle's algorithm so that data is sent immediately.
OutOfBandInline (inherited from Tcp) | Gets or sets a value that indicates whether out-of-band (urgent) data is read as normal in-line data.
Proxy (inherited from Tcp) | Returns the Proxy instance that controls proxy server use.
ReceiveBufferSize (inherited from Tcp) | Gets and sets the size of the system receive buffer.
ReceiveTimeout (inherited from Tcp) | Gets and sets the number of milliseconds that a Tcp.Receive method will block before throwing a SocketException.
RemoteEndPoint (inherited from Tcp) | Returns the remote address/port the socket is connected to.
ReuseAddress (inherited from Tcp) | Gets or sets a value that typically allows any local port to be specified, even if it is already in use.
SendBufferSize (inherited from Tcp) | Gets and sets the size of the system send buffer.
SendTimeout (inherited from Tcp) | Gets and sets the number of milliseconds that a Tcp.Send method will block before throwing a SocketException.
ServerOptions | Contains the current server options for a Telnet session.
Site (inherited from Component) | Gets or sets the ISite of the Component.
Socket (inherited from Tcp) | Returns a reference to the System.Net.Sockets.Socket instance being used.
Stream (inherited from Tcp) | Returns a SegmentedStream that can be used for advanced streaming operations on the socket.
SynchronizingObject (inherited from Tcp) | Set this object to automatically control thread marshalling between worker threads and the main UI thread.
Tag (inherited from Tcp) | Gets or sets an object reference that can be used to associate this instance with any other.
TerminalType | Gets or sets a value representing the client's terminal type.
WindowSize | Gets or sets a value representing the client's window size.

See Also

Telnet Class | Dart.PowerTCP.Telnet Namespace


Telnet.Binary Property

Gets or sets a value which indicates if the TRANSMIT-BINARY option should be negotiated for both client and server.

[Visual Basic]
Public Property Binary As OptionState
[C#]
public OptionState Binary {get; set;}

Property Value

true if you wish for the TRANSMIT-BINARY option be negotiated for client and server; false otherwise. The default value is false.

Remarks

Setting this property to true causes the Telnet control to attempt to negotiate the TRANSMIT-BINARY option for both the client and server (the OptionCode.TransmitBinary option is added to both Telnet.ClientOptions and Telnet.ServerOptions). To determine if negotiation is successful, check the Option in both the Telnet.ClientOptions and Telnet.ServerOptions collections. If the Option.State property of these Option objects is OptionState.On for both, negotiation was successful.

The TRANSMIT-BINARY option is used to send data without padding naked CR characters with NULL. When enabled, this option indicates that naked CR's (A CR not part of a CR/LF sequence) are transmitted without adding a NULL after the CR, and are received without stripping the NULL off of any CR/NULL sequence found.

See Also

Telnet Class | Dart.PowerTCP.Telnet Namespace


Telnet.ClientOptions Property

Contains the current client options for a Telnet session.

[Visual Basic]
Public ReadOnly Property ClientOptions As OptionCollection
[C#]
public OptionCollection ClientOptions {get;}

Property Value

An Options object containing the current Options for the Telnet session.

Remarks

Using PowerTCP Telnet for .NET, option negotiation occurs like so:

  • If you wish for a client option to be requested during negotiation, add the Option to Telnet.ClientOptions with OptionState.RequestOn.
  • If you wish for a server option to be requested during negotiation, add the Option to Telnet.ServerOptions with OptionState.RequestOn.
  • If you do not want an option to be requested during option negotiation do not add it to either collection. If it is already in a collection, remove it.

When option negotiation occurs (typically after a connection is made) each Option in Telnet.ClientOptions is sent with a "Will" command. If the server sends a "Do" request to attempt to enable an option that is not in Telnet.ClientOptions, the Telnet control will respond with "Wont". Each Option in Telnet.ServerOptions is sent with a "Do" or "Dont" command, depending on whether or not Option.State is OptionState.RequestOn or OptionState.RequestOff. While the command is sent and the response has not been received from the server, the Option.State is OptionState.Waiting. When the response is received from the server the Option.State will be changed to OptionState.On or OptionState.Off, depending on whether or not the option is successfully negotiated.

The Telnet.ClientOptionChanged event is raised whenever the Option.State property changes for an Option contained within the ClientOptions collection.

Example

[Visual Basic, C#] The following example demonstrates customizing the default option negotiation sequence.

[Visual Basic]
' Cause the client to refuse the TerminalType option if offered by the server
Telnet1.ClientOptions.Remove(Telnet1.ClientOptions(OptionCode.TerminalType))

' Request that server enable the Echo option
Telnet1.ServerOptions.Add(New Option(OptionCode.Echo))

' ReceiveTimeout must be set to a positive value before using the Login method.
Telnet1.ReceiveTimeout = 3000

' Connect and login to the Telnet server
Telnet1.Login("myserver", "myusername", "mypassword", "$")

' What is the result of option negotiation?
Dim o as Option
For Each o in Telnet1.ClientOptions
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
Next

For Each o in Telnet1.ServerOptions
    Debug.WriteLine("Code: " + o.Code)
    Debug.WriteLine("State: " + o.State)
Next
[C#]
// Cause the client to refuse the TerminalType option if offered by the server
telnet1.ClientOptions.Remove(telnet1.ClientOptions[OptionCode.TerminalType]);

// Request that server enable the Echo option
telnet1.ServerOptions.Add(new Option(OptionCode.Echo));

// Connect and login to the Telnet server
telnet1.Login("myserver", "myusername", "mypassword", "$");

// What is the result of option negotiation?
foreach(Option o in telnet1.ClientOptions)
{
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
}
foreach(Option o in telnet1.ClientOptions)
{
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Telnet Class | Dart.PowerTCP.Telnet Namespace


Telnet.Echo Property

Gets or sets a value which inidicates that the ECHO option should be negotiated.

[Visual Basic]
Public Property Echo As OptionState
[C#]
public OptionState Echo {get; set;}

Property Value

OptionState.RequestOn if the ECHO option should be negotiated; OptionState.Off otherwise. The default value is OptionState.Off.

Remarks

When the ECHO option is used, all data the server receives from the client is echoed back to the client. This property only operates on the Telnet.ServerOptions collection.

See Also

Telnet Class | Dart.PowerTCP.Telnet Namespace


Telnet.Editor Property

In Visual Studio.NET, displays an interactive form to use to test real time protocol operations.

[Visual Basic]
Public Property Editor As Object
[C#]
public object Editor {get; set;}

Property Value

An EditorForm to use in VS.NET to test protocol operations.

Remarks

This property can only be used by clicking this property in the Properties Window in Visual Studio.NET. This will open an application which can be used to test protocol operation. The EditorForm will not be available if the PowerTCP component is being used as a reference.

The Object.Editor property can ONLY be used at design time in the Visual Studio.NET environment.

See Also

Telnet Class | Dart.PowerTCP.Telnet Namespace


Telnet.ServerOptions Property

Contains the current server options for a Telnet session.

[Visual Basic]
Public ReadOnly Property ServerOptions As OptionCollection
[C#]
public OptionCollection ServerOptions {get;}

Property Value

An Options object containing the current Options for the Telnet session.

Remarks

Using PowerTCP Telnet for .NET, option negotiation occurs like so:

  • If you wish for a client option to be requested during negotiation, add the Option to Telnet.ClientOptions with OptionState.RequestOn.
  • If you wish for a server option to be requested during negotiation, add the Option to Telnet.ServerOptions with OptionState.RequestOn.
  • If you do not want an option to be requested during option negotiation do not add it to either collection. If it is already in a collection, remove it.

When option negotiation occurs (typically after a connection is made) each Option in Telnet.ClientOptions is sent with a "Will" command. If the server sends a "Do" request to attempt to enable an option that is not in Telnet.ClientOptions, the Telnet control will respond with "Wont". Each Option in Telnet.ServerOptions is sent with a "Do" or "Dont" command, depending on whether or not Option.State is OptionState.RequestOn or OptionState.RequestOff. While the command is sent and the response has not been received from the server, the Option.State is OptionState.Waiting. When the response is received from the server the Option.State will be changed to OptionState.On or OptionState.Off, depending on whether or not the option is successfully negotiated.

The Telnet.ServerOptionChanged event is raised whenever the Option.State property changes for an Option contained within the ServerOptions collection.

Example

[Visual Basic, C#] The following example demonstrates customizing the default option negotiation sequence.

[Visual Basic]
' Cause the client to refuse the TerminalType option if offered by the server
Telnet1.ClientOptions.Remove(Telnet1.ClientOptions(OptionCode.TerminalType))

' Request that server enable the Echo option
Telnet1.ServerOptions.Add(New Option(OptionCode.Echo))

' ReceiveTimeout must be set to a positive value before using the Login method.
Telnet1.ReceiveTimeout = 3000

' Connect and login to the Telnet server
Telnet1.Login("myserver", "myusername", "mypassword", "$")

' What is the result of option negotiation?
Dim o as Option
For Each o in Telnet1.ClientOptions
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
Next

For Each o in Telnet1.ServerOptions
    Debug.WriteLine("Code: " + o.Code)
    Debug.WriteLine("State: " + o.State)
Next
[C#]
// Cause the client to refuse the TerminalType option if offered by the server
telnet1.ClientOptions.Remove(telnet1.ClientOptions[OptionCode.TerminalType]);

// Request that server enable the Echo option
telnet1.ServerOptions.Add(new Option(OptionCode.Echo));

// Connect and login to the Telnet server
telnet1.Login("myserver", "myusername", "mypassword", "$");

// What is the result of option negotiation?
foreach(Option o in telnet1.ClientOptions)
{
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
}
foreach(Option o in telnet1.ClientOptions)
{
   Debug.WriteLine("Code: " + o.Code)
   Debug.WriteLine("State: " + o.State)
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Telnet Class | Dart.PowerTCP.Telnet Namespace


Telnet.TerminalType Property

Gets or sets a value representing the client's terminal type.

[Visual Basic]
Public Property TerminalType As String
[C#]
public string TerminalType {get; set;}

Property Value

A string representing the client's terminal type. Defaults to "tty".

Remarks

Many hosts send a TERMINAL-TYPE request during option negotiation. By setting this property at design time or before connecting, the control responds with this value during the automatic option negotiation.

See Also

Telnet Class | Dart.PowerTCP.Telnet Namespace


Telnet.WindowSize Property

Gets or sets a value representing the client's window size.

[Visual Basic]
Public Property WindowSize As Size
[C#]
public System.Drawing.Size WindowSize {get; set;}

Property Value

A System.Drawing.Size type representing the client's window size. The default values are Height = 80 and Width = 24.

Remarks

Many hosts send a terminal window size request shortly after a Telnet connection is established. By setting this property at design time or before connecting, the control responds with this value during the automatic option negotiation.

See Also

Telnet Class | Dart.PowerTCP.Telnet Namespace


Telnet Methods

The methods of the Telnet class are listed below. For a complete list of Telnet class members, see the Telnet Members topic.

Public Instance Methods

BeginConnect (inherited from Tcp) | Overloaded. Connect to a server asynchronously, specifying the local interface and a range of local ports to use. The Tcp.EndConnect event is raised when completed.
BeginConnect | Overloaded. Connect to a server asynchronously. The Telnet.EndConnect event is raised when completed.
BeginReceive (inherited from Tcp) | Overloaded. Receive data into your buffer asynchronously specifying a buffer, offset, size and SocketFlags value. The Tcp.EndReceive event is raised when completed.
BeginSend (inherited from Tcp) | Overloaded. Send data from your buffer asynchronously, specifying a buffer, offset, size and SocketFlags value. The Tcp.EndSend event is raised when completed.
Close (inherited from Tcp) | Overloaded. Close the connection.
Connect (inherited from Tcp) | Overloaded. Connect to a host, specifying the local interface and a range of local ports to use.
Connect | Overloaded. Connect to a host.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from Component) | Releases all resources used by the Component.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Login | Connects to a Telnet server and attempts to automatically login.
Receive (inherited from Tcp) | Overloaded. Receive data from the host, specifying a buffer, offset, size and SocketFlags value.
Refresh | Performs option negotiation for any option that has not yet been sent.
Send (inherited from Tcp) | Overloaded. Send data to the server, specifying a buffer, offset, size and SocketFlags value.
SendCommand | Send a Telnet control function.
SendOption | Send option data to the remote host.
SendSubOption | Send suboption data to the remote host.
ToString (inherited from Component) |
WaitFor | Reads data from the stream until the specified string is found.

See Also

Telnet Class | Dart.PowerTCP.Telnet Namespace


BeginConnect Method

PowerTCP Telnet for .NET

Telnet.BeginConnect Method

Connect to a server asynchronously. The Telnet.EndConnect event is raised when completed.

Overload List

Connect to a server asynchronously. The Telnet.EndConnect event is raised when completed.

public IAsyncResult BeginConnect(string);

Inherited from Tcp.

public IAsyncResult BeginConnect(string,int);

Inherited from Tcp.

public virtual IAsyncResult BeginConnect(string,int,string,int,int,object);

Inherited from Tcp.

public IAsyncResult BeginConnect(string,int,string,int,object);

See Also

Telnet Class | Dart.PowerTCP.Telnet Namespace


Telnet.BeginConnect Method (String)

Connect to a server asynchronously. The Telnet.EndConnect event is raised when completed.

[Visual Basic]
Overloads Public Function BeginConnect( _
ByVal server As String _
) As IAsyncResult
[C#]
public IAsyncResult BeginConnect(
string server
);

Parameters

server
Remote hostname or address in dot notation.

Return Value

An IAsyncResult that represents the asynchronous operation, which could still be pending.

Remarks

Use this method if you wish to connect to a host on the "well-known" TELNET port 23 transparently with minimal application impact, as execution occurs on another thread. This method begins to asynchronously connect to the server. Upon completion (on both success and failure) the Telnet.EndConnect event is raised. An EventArgs object is passed into this event, containing information about the event. If the connection succeeds, the ConnectedChanged event is raised. Once the connection has been made, you can send and receive data from the remote device.

Automatic negotiation takes place once the connection is successfully made.

If you are using the Telnet component as a reference, you must "wire up" the event yourself. This involves creating a method as the event handler that implements the EventHandler delegate.

For more information on implementing and handling events using PowerTCP.NET, see the topic, "Using Events In PowerTCP".

To connect synchronously, use the Telnet.Connect method.

Exceptions

Exception Type | Condition
InvalidOperationException | BeginXXX method used without providing an EndXXX event handler.

See Also

Telnet Class | Dart.PowerTCP.Telnet Namespace | Telnet.BeginConnect Overload List


Connect Method

PowerTCP Telnet for .NET

Telnet.Connect Method

Connect to a host.

Overload List

Connect to a host.

public void Connect(string);

Inherited from Tcp.

public void Connect(string,int);

Inherited from Tcp.

public void Connect(string,int,string,int);

Inherited from Tcp.

public virtual void Connect(string,int,string,int,int);

Inherited from Tcp.

public void Connect(string,string);

See Also

Telnet Class | Dart.PowerTCP.Telnet Namespace


Telnet.Connect Method (String)

Connect to a host.

[Visual Basic]
Overloads Public Sub Connect( _
ByVal server As String _
)
[C#]
public void Connect(
string server
);

Parameters

server
Remote hostname or address in dot notation.

Remarks

The Telnet.Connect method establishes a network connection between the default local network interface/port and the device identified by remote network address and the "well-known" TELNET port 23. If no exception is thrown, the connection has succeeded and the Telnet.Connected property will return true after this method returns. Once the connection has been made, you can send/receive data to/from the server.

This method always blocks until the attempted connection succeeds or fails.

Exceptions

Exception Type | Condition
SocketException | The remote host cannot be found.

Example

[Visual Basic, C#] The following example demonstrates using the Telnet.WaitFor method to read from the stream until a delimiter is found. Note: This entire code snippet is replaced by the Telnet.Login method and is just shown here for demonstration purposes.

[Visual Basic]
Try
   ' Connect to a server
   Telnet1.Connect("myserver")

   ' Read until "login" is found (change to whatever prompt your server uses).
   Telnet1.WaitFor("login:")

   ' Login received, send username
   Telnet1.Send("myuser" + vbCRLf)

   ' Now wait until "Password:" is found
   Telnet1.WaitFor("Password:")

   ' Send password
   Telnet1.Send("mypass" + vbCrLf);

   ' Wait for command prompt
   Telnet1.WaitFor("$ ")

   ' Logged in.
}
Catch ex As Exception
   Debug.WriteLine(ex.Message)
End Try
[C#]
try
{
   // Connect to a server
   telnet1.Connect("myserver");

   // Read until "login" is found (change to whatever prompt your server uses).
   telnet1.WaitFor("login:");

   // Login received, send username
   telnet1.Send("myuser\r\n");

   // Now wait until "Password:" is found
   telnet1.WaitFor("Password:");

   // Send password
   telnet1.Send("mypass\r\n");

   // Wait for command prompt
   telnet1.WaitFor("$");

   // Logged in.
}
catch(Exception ex)
{
   Debug.WriteLine(ex.Message);
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Telnet Class | Dart.PowerTCP.Telnet Namespace | Telnet.Connect Overload List


Telnet.Login Method

Connects to a Telnet server and attempts to automatically login.

[Visual Basic]
Public Function Login( _
ByVal server As String, _
ByVal username As String, _
ByVal password As String, _
ByVal commandPrompt As String _
) As Segment
[C#]
public Segment Login(
string server,
string username,
string password,
string commandPrompt
);

Parameters

server
The server to connect to.
username
The username to issue when a login prompt is found.
password
The password to issue when a password prompt is found.
commandPrompt
The prompt to search for.

Return Value

A Segment object containing all data read from the stream during the login procedure.

Remarks

This method simplifies the login procedure by connecting to a Telnet server, reading data until a login prompt is found, issuing a username, reading until a password prompt is found, issuing a password, then reading until a command prompt is found. If this succeeds, the Telnet component is logged in and ready to send commands.

During this operation, the Telnet component will block for the value of Telnet.ReceiveTimeout while searching for login/password prompts. Note: If login fails (for example, if the incorrect password was entered) no Exception is thrown. You must check the data within the Segment object returned from the method to determine if login was successful.

If the server uses unexpected login prompts (for example if the server sends "username:" where the Telnet component expects "login:") the method will still work. If a timeout occurs while waiting for the string "login:", the Telnet component will just assume it received the equivalent of a "login:" prompt and send the username. For this reason, if a server uses unexpected prompts, login will take longer than if a server uses expected prompts because the Telnet component will have to wait for the timeout before sending the command.

Note: The server may take over 3 seconds to check disk quotas and perform other tasks before responding to the Telnet component. For this reason, the minimum Telnet.ReceiveTimeout value should be 3000.

Exceptions

Exception Type | Condition
InvalidOperationException | Telnet.AutoReceive is set to true (must be false) or Telnet.ReceiveTimeout is set to 0 (must be a positive number).
SocketException | Server did not reply in the expected amount of time.

Example

[Visual Basic, C#] The following example demonstrates basic Telnet usage.

[Visual Basic]
' Set ReceiveTimeout to nonzero, required for Login method
Telnet1.ReceiveTimeout = 3000

' Login
Telnet1.Login("myserver", "myuser", "mypass", "$ ")

' Send a command
Telnet1.Send("pwd" + vbCrLf)

' Receive the response
Dim Seg As Segment = Telnet1.Receive()
Debug.WriteLine(Seg.ToString())

' Close the connection
Telnet1.Close()
[C#]
// Set ReceiveTimeout to nonzero, required for Login method
telnet1.ReceiveTimeout = 3000;

// Login
telnet1.Login("myserver", "myuser", "mypass", "$ ");

// Send a command
telnet1.Send("pwd\r\n");

// Receive the response
Segment seg = telnet1.Receive();
Debug.WriteLine(seg.ToString());

// Close the connection
telnet1.Close();

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Telnet Class | Dart.PowerTCP.Telnet Namespace


Telnet.Refresh Method

Performs option negotiation for any option that has not yet been sent.

[Visual Basic]
Public Sub Refresh()
[C#]
new public void Refresh();

Remarks

This method performs option negotiation for any non-negotiated option. Essentially, requests for all Option objects with Option.State = OptionState.RequestOff or OptionState.RequestOn are sent to the server. The Telnet control automatically calls this method when connecting and sending/receiving data to initialize option negotiation.

See Also

Telnet Class | Dart.PowerTCP.Telnet Namespace


Telnet.SendCommand Method

Send a Telnet control function.

[Visual Basic]
Public Function SendCommand( _
ByVal command As Command _
) As Segment
[C#]
public Segment SendCommand(
Command command
);

Parameters

command
The Command to send to the server.

Return Value

A Segment object encapsulating the bytes sent.

Remarks

Telnet control functions are commands which represent functions that are implemented on most servers. For example, most servers provide a function that allows the user to interrupt or abort a process. This is represented by the Telnet control function "IP". Send the "IP" function to the server to cause the server to invoke the function which interrupts or aborts the process. A list of control functions are accessable in the Command topic. Use the Telnet.SendCommand method to send these control functions to the server.

If you wish to perform your own option negotiation (outside of the Telnet components automatic option negotiation) use the Telnet.SendOption method.

See Also

Telnet Class | Dart.PowerTCP.Telnet Namespace


Telnet.SendOption Method

Send option data to the remote host.

[Visual Basic]
Public Sub SendOption( _
ByVal command As Command, _
ByVal code As OptionCode _
)
[C#]
public void SendOption(
Command command,
OptionCode code
);

Parameters

command
The command to send with the option.
code
The option you would like to negotiate about.

Remarks

Typically, option negotiation occurs automatically when using the Telnet component. Use this method ONLY if you wish to disable the automatic negotiation. To disable the automatic negotiation, you must do the following:

  1. Clear both the Telnet.ClientOptions and Telnet.ServerOptions collections.
  2. Use the Telnet.SendOption method from within the Telnet.CommandReceivedEvent in response to a command from the server.

Once automatic option negotiation had been disabled, you must negotiate all options yourself.

See Also

Telnet Class | Dart.PowerTCP.Telnet Namespace


Telnet.SendSubOption Method

Send suboption data to the remote host.

[Visual Basic]
Public Function SendSubOption( _
ByVal code As OptionCode, _
ByVal subOption As Byte() _
) As Segment
[C#]
public Segment SendSubOption(
OptionCode code,
byte[] subOption
);

Parameters

code
The option that the suboption is providing additional info for.
subOption
The suboption data itself. Refer to the particular option RFC for formatting info.

Return Value

A Segment object describing the data sent.

Remarks

Typically, suboption data is sent automatically by the Telnet component when a new Option (containing the appropriate suboption data) is added to either the Telnet.ClientOptions or Telnet.ServerOptions collections. Use this method ONLY if you are not using the automatic option negotiation. Please refer to the option RFC for more information about sending suboptions.

See Also

Telnet Class | Dart.PowerTCP.Telnet Namespace


Telnet.WaitFor Method

Reads data from the stream until the specified string is found.

[Visual Basic]
Public Function WaitFor( _
ByVal prompt As String _
) As String
[C#]
public string WaitFor(
string prompt
);

Parameters

prompt
Data is read until this string is found.

Return Value

A string containing all data read from the stream.

Remarks

This method reads from the data stream until the specified string is found or the method times out. Often, it is useful when communicating with a server to be able to read data until a token is found. For example, during the login operation the server may send a string "login:". You could use the Telnet.WaitFor method to keep reading until you find "login:", then issue your login command.

This method will block for the amount of time specified in Rlogin.ReceiveTimeout. If Rlogin.ReceiveTimeout is 0, this method will throw a System.InvalidOperationException. If prompt is not found within the time specified by Telnet.ReceiveTimeout, a System.SocketException is thrown (with the timeout ErrorCode of 10060).

Exceptions

Exception Type | Condition
SocketException | prompt was not found within the specified period of time.
InvalidOperationException | Telnet.ReceiveTimeout is 0.

Example

[Visual Basic, C#] The following example demonstrates using the Telnet.WaitFor method to read from the stream until a delimiter is found. Note: This entire code snippet is replaced by the Telnet.Login method and is just shown here for demonstration purposes.

[Visual Basic]
Try
   ' Connect to a server
   Telnet1.Connect("myserver")

   ' Read until "login" is found (change to whatever prompt your server uses).
   Telnet1.WaitFor("login:")

   ' Login received, send username
   Telnet1.Send("myuser" + vbCRLf)

   ' Now wait until "Password:" is found
   Telnet1.WaitFor("Password:")

   ' Send password
   Telnet1.Send("mypass" + vbCrLf);

   ' Wait for command prompt
   Telnet1.WaitFor("$ ")

   ' Logged in.
}
Catch ex As Exception
   Debug.WriteLine(ex.Message)
End Try
[C#]
try
{
   // Connect to a server
   telnet1.Connect("myserver");

   // Read until "login" is found (change to whatever prompt your server uses).
   telnet1.WaitFor("login:");

   // Login received, send username
   telnet1.Send("myuser\r\n");

   // Now wait until "Password:" is found
   telnet1.WaitFor("Password:");

   // Send password
   telnet1.Send("mypass\r\n");

   // Wait for command prompt
   telnet1.WaitFor("$");

   // Logged in.
}
catch(Exception ex)
{
   Debug.WriteLine(ex.Message);
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Telnet Class | Dart.PowerTCP.Telnet Namespace


Telnet Events

The events of the Telnet class are listed below. For a complete list of Telnet class members, see the Telnet Members topic.

Public Instance Events

ClientOptionChanged | Raised when a client Telnet option has changed state (WILL or WONT confirmed).
CommandReceived | This event is raised when a Telnet command has been received from the server.
ConnectedChanged (inherited from Tcp) | Raised when the value of the Object.Connected property changes.
Disposed (inherited from Component) | Adds an event handler to listen to the Disposed event on the component.
EndConnect (inherited from Tcp) | Raised when the Tcp.BeginConnect request completes.
EndReceive (inherited from Tcp) | Raised when the Tcp.BeginReceive request completes.
EndSend (inherited from Tcp) | Raised when the Tcp.BeginSend request completes.
RawTrace (inherited from Tcp) | Raised when data has been sent/received.
ServerOptionChanged | Raised when a server Telnet option has changed state (DO or DONT confirmed).
Trace (inherited from Tcp) | Raised when data has been sent/received.

See Also

Telnet Class | Dart.PowerTCP.Telnet Namespace


Telnet.ClientOptionChanged Event

Raised when a client Telnet option has changed state (WILL or WONT confirmed).

[Visual Basic]
Public Event ClientOptionChanged As OptionEventHandler
[C#]
public event OptionEventHandler ClientOptionChanged;

Event Data

The event handler receives an argument of type OptionEventArgs containing data related to this event. The following OptionEventArgs property provides information specific to this event.

Property | Description
Option | Represents the option that has changed in an OptionChanged event.

See Also

Telnet Class | Dart.PowerTCP.Telnet Namespace


Telnet.CommandReceived Event

This event is raised when a Telnet command has been received from the server.

[Visual Basic]
Public Event CommandReceived As CommandEventHandler
[C#]
public event CommandEventHandler CommandReceived;

Event Data

The event handler receives an argument of type CommandEventArgs containing data related to this event. The following CommandEventArgs properties provide information specific to this event.

Property | Description
Command | Represents the command sent by the remote host.
OptionCode | Represents the option to which the command pertains.
SubOption | Contains the suboption data.

Remarks

A CommandEventArgs object is passed into the event handler, containing information required to handle the command. For example, the CommandEventArgs.Command property contains the Command sent from the server.

If any reply is sent to the server from within the Telnet.CommandReceived event by using the Telnet.SendOption method, it is assumed that option negotiation will be handled by the developer and automatic option negotion is turned off.

See Also

Telnet Class | Dart.PowerTCP.Telnet Namespace


Telnet.ServerOptionChanged Event

Raised when a server Telnet option has changed state (DO or DONT confirmed).

[Visual Basic]
Public Event ServerOptionChanged As OptionEventHandler
[C#]
public event OptionEventHandler ServerOptionChanged;

Event Data

The event handler receives an argument of type OptionEventArgs containing data related to this event. The following OptionEventArgs property provides information specific to this event.

Property | Description
Option | Represents the option that has changed in an OptionChanged event.

See Also

Telnet Class | Dart.PowerTCP.Telnet Namespace


TelnetStream Class

Performs Telnet-specific formatting of data passing through the stream.

For a list of all members of this type, see TelnetStream Members.

System.Object
MarshalByRefObject
Stream
EnhancedStream
PipeStream
TelnetStream

[Visual Basic]
Public Class TelnetStream
Inherits PipeStream
[C#]
public class TelnetStream : PipeStream

Remarks

Telnet builds upon TCP by providing support for option negotiation. The TelnetStream object enables the option negotiation and formatting support for data.

When a new Telnet component is created, the Telnet.Stream property is initialized with a new Telnet Stream. This means all data sent/received using Telnet.Send, Telnet.Receive, Telnet.Stream.Read, or Telnet.Stream.Write will pass throgh the TelnetStream, which applies the necessary formatting and handles other Telnet-related functionality.

Requirements

Namespace: Dart.PowerTCP.Telnet

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

TelnetStream Members | Dart.PowerTCP.Telnet Namespace


TelnetStream Members

TelnetStream overview

Public Instance Constructors

TelnetStream Overloaded. Initializes a new instance of the TelnetStream class.

Public Instance Properties

Available | Gets the amount of data that has been received from the network and is available to be read.
CanRead (inherited from PipeStream) | Gets a value indicating whether the current Stream supports reading.
CanSeek (inherited from EnhancedStream) | Gets a value indicating whether the current stream supports seeking.
CanWrite (inherited from EnhancedStream) | Gets a value indicating whether the current stream supports writing.
Charset (inherited from EnhancedStream) | Gets and sets the character set used for string/byte array conversions.
ClientOptions | Contains the current client options for a Telnet session.
CoreStream (inherited from PipeStream) | The internal stream to which all buffered reads/writes are being made.
Encoding (inherited from EnhancedStream) | Gets or sets the type of encoding to use.
Length (inherited from PipeStream) | Gets the length in bytes of the stream.
Position (inherited from PipeStream) | Gets or sets the position within the current stream
ServerOptions | Contains the current server options for a Telnet session.

Public Instance Methods

BeginRead (inherited from Stream) | Begins an asynchronous read operation.
BeginWrite (inherited from Stream) | Begins an asynchronous write operation.
Close | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from EnhancedStream) | Overloaded. Releases all resources associated with the object.
EndRead (inherited from Stream) | Waits for the pending asynchronous read to complete.
EndWrite (inherited from Stream) | Ends an asynchronous write operation.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Flush (inherited from PipeStream) | Updates the underlying data source or repository with the current state of the buffer and then clears the buffer.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Read | Overloaded. Read data from the stream while applying Telnet-specific formatting.
Read (inherited from EnhancedStream) | Overloaded. When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
ReadByte (inherited from Stream) | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
Refresh | Performs option negotiation for any option that has not yet been sent.
Reset | Returns all OptionState to their original setting when added to the collection.
Save (inherited from EnhancedStream) | Overloaded. Saves the data in the stream to the file specified by fileName.
Seek (inherited from EnhancedStream) | Sets the position within the current Stream to the specified value. Always throws a NotSupportedException.
SendCommand | Send a Telnet control function.
SendOption | Send option data to the remote host.
SendSubOption | Send suboption data to the remote host.
SetLength (inherited from EnhancedStream) | Sets the length of the current Stream to the specified value. Always throws a NotSupportedException.
ToArray (inherited from EnhancedStream) | Returns the byte array representation of the Stream data.
ToString (inherited from EnhancedStream) | Returns the string representation of the Stream data.
Write | Overloaded. Writes data to the stream while applying Telnet-specific formatting.
Write (inherited from EnhancedStream) | Overloaded. When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
WriteByte (inherited from Stream) | Writes a byte to the current position in the stream and advances the position within the stream by one byte.
WriteTo (inherited from EnhancedStream) | Overloaded. Writes all of the data contained in this Stream to a destination Stream.

Public Instance Events

ClientOptionChanged | This event is raised when the Option.State of a ClientOption has changed.
CommandReceived | This event is raised when a Telnet command has been received from the server.
ServerOptionChanged | This event is raised when the Option.State of a ServerOption has changed.

Explicit Interface Implementations

IDisposable.Dispose (inherited from Stream)

See Also

TelnetStream Class | Dart.PowerTCP.Telnet Namespace


TelnetStream Constructor

Creates a new instance of TelnetStream.

Overload List

Creates a new instance of TelnetStream.

public TelnetStream();

Creates a new instance of TelnetStream.

public TelnetStream(Stream,Encoding);

See Also

TelnetStream Class | Dart.PowerTCP.Telnet Namespace


TelnetStream Constructor (Stream, Encoding)

Creates a new instance of TelnetStream.

[Visual Basic]
Overloads Public Sub New( _
ByVal stream As Stream, _
ByVal encoding As Encoding _
)
[C#]
public TelnetStream(
Stream stream,
Encoding encoding
);

Remarks

The default constructor creates a new instance of TelnetStream.

See Also

TelnetStream Class | Dart.PowerTCP.Telnet Namespace | TelnetStream Constructor Overload List


TelnetStream Constructor ()

Creates a new instance of TelnetStream.

[Visual Basic]
Overloads Public Sub New()
[C#]
public TelnetStream();

Remarks

The default constructor creates a new instance of TelnetStream.

See Also

TelnetStream Class | Dart.PowerTCP.Telnet Namespace | TelnetStream Constructor Overload List


TelnetStream Properties

The properties of the TelnetStream class are listed below. For a complete list of TelnetStream class members, see the TelnetStream Members topic.

Public Instance Properties

Available | Gets the amount of data that has been received from the network and is available to be read.
CanRead (inherited from PipeStream) | Gets a value indicating whether the current Stream supports reading.
CanSeek (inherited from EnhancedStream) | Gets a value indicating whether the current stream supports seeking.
CanWrite (inherited from EnhancedStream) | Gets a value indicating whether the current stream supports writing.
Charset (inherited from EnhancedStream) | Gets and sets the character set used for string/byte array conversions.
ClientOptions | Contains the current client options for a Telnet session.
CoreStream (inherited from PipeStream) | The internal stream to which all buffered reads/writes are being made.
Encoding (inherited from EnhancedStream) | Gets or sets the type of encoding to use.
Length (inherited from PipeStream) | Gets the length in bytes of the stream.
Position (inherited from PipeStream) | Gets or sets the position within the current stream
ServerOptions | Contains the current server options for a Telnet session.

See Also

TelnetStream Class | Dart.PowerTCP.Telnet Namespace


TelnetStream.Available Property

Gets the amount of data that has been received from the network and is available to be read.

[Visual Basic]
Public ReadOnly Property Available As Integer
[C#]
public int Available {get;}

Property Value

The number of bytes of data that has been received from the network and are available to be read.

Remarks

When data is received from the network, it is collected in system buffers. The Tcp.Available property contains the amount of bytes of data that has been received. In order to receive the data into a useful data structure such as a string, byte array, or Segment object that you can use within your application you must use the Tcp.Receive or Tcp.Stream.Read methods. If these methods are not invoked or are seldom invoked, then "back pressure" is exerted at the remote host and packet transmission rates will decrease. If these methods are invoked, the data is received and removed from the system buffers, making room for more data to be received from the network.

See Also

TelnetStream Class | Dart.PowerTCP.Telnet Namespace


TelnetStream.ClientOptions Property

Contains the current client options for a Telnet session.

[Visual Basic]
Public ReadOnly Property ClientOptions As OptionCollection
[C#]
public OptionCollection ClientOptions {get;}

Property Value

An Options object containing the current Options for the Telnet session.

Remarks

Using PowerTCP Telnet for .NET, option negotiation occurs like so:

  • If you wish for a client option to be requested during negotiation, add the Option to Telnet.ClientOptions with OptionState.RequestOn.
  • If you wish for a server option to be requested during negotiation, add the Option to Telnet.ServerOptions with OptionState.RequestOn.
  • If you do not want an option to be requested during option negotiation do not add it to either collection. If it is already in a collection, remove it.

When option negotiation occurs (typically after a connection is made) each Option in Telnet.ClientOptions is sent with a "Will" command. If the server sends a "Do" request to attempt to enable an option that is not in Telnet.ClientOptions, the Telnet control will respond with "Wont". Each Option in Telnet.ServerOptions is sent with a "Do" or "Dont" command, depending on whether or not Option.State is OptionState.RequestOn or OptionState.RequestOff. While the command is sent and the response has not been received from the server, the Option.State is OptionState.Waiting. When the response is received from the server the Option.State will be changed to OptionState.On or OptionState.Off, depending on whether or not the option is successfully negotiated.

The Telnet.ClientOptionChanged event is raised whenever the Option.State property changes for an Option contained within the ClientOptions collection.

See Also

TelnetStream Class | Dart.PowerTCP.Telnet Namespace


TelnetStream.ServerOptions Property

Contains the current server options for a Telnet session.

[Visual Basic]
Public ReadOnly Property ServerOptions As OptionCollection
[C#]
public OptionCollection ServerOptions {get;}

Property Value

An Options object containing the current Options for the Telnet session.

Remarks

Using PowerTCP Telnet for .NET, option negotiation occurs like so:

  • If you wish for a client option to be requested during negotiation, add the Option to Telnet.ClientOptions with OptionState.RequestOn.
  • If you wish for a server option to be requested during negotiation, add the Option to Telnet.ServerOptions with OptionState.RequestOn.
  • If you do not want an option to be requested during option negotiation do not add it to either collection. If it is already in a collection, remove it.

When option negotiation occurs (typically after a connection is made) each Option in Telnet.ClientOptions is sent with a "Will" command. If the server sends a "Do" request to attempt to enable an option that is not in Telnet.ClientOptions, the Telnet control will respond with "Wont". Each Option in Telnet.ServerOptions is sent with a "Do" or "Dont" command, depending on whether or not Option.State is OptionState.RequestOn or OptionState.RequestOff. While the command is sent and the response has not been received from the server, the Option.State is OptionState.Waiting. When the response is received from the server the Option.State will be changed to OptionState.On or OptionState.Off, depending on whether or not the option is successfully negotiated.

The Telnet.ServerOptionChanged event is raised whenever the Option.State property changes for an Option contained within the ServerOptions collection.

See Also

TelnetStream Class | Dart.PowerTCP.Telnet Namespace


TelnetStream Methods

The methods of the TelnetStream class are listed below. For a complete list of TelnetStream class members, see the TelnetStream Members topic.

Public Instance Methods

BeginRead (inherited from Stream) | Begins an asynchronous read operation.
BeginWrite (inherited from Stream) | Begins an asynchronous write operation.
Close | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from EnhancedStream) | Overloaded. Releases all resources associated with the object.
EndRead (inherited from Stream) | Waits for the pending asynchronous read to complete.
EndWrite (inherited from Stream) | Ends an asynchronous write operation.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Flush (inherited from PipeStream) | Updates the underlying data source or repository with the current state of the buffer and then clears the buffer.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Read | Overloaded. Read data from the stream while applying Telnet-specific formatting.
Read (inherited from EnhancedStream) | Overloaded. When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
ReadByte (inherited from Stream) | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
Refresh | Performs option negotiation for any option that has not yet been sent.
Reset | Returns all OptionState to their original setting when added to the collection.
Save (inherited from EnhancedStream) | Overloaded. Saves the data in the stream to the file specified by fileName.
Seek (inherited from EnhancedStream) | Sets the position within the current Stream to the specified value. Always throws a NotSupportedException.
SendCommand | Send a Telnet control function.
SendOption | Send option data to the remote host.
SendSubOption | Send suboption data to the remote host.
SetLength (inherited from EnhancedStream) | Sets the length of the current Stream to the specified value. Always throws a NotSupportedException.
ToArray (inherited from EnhancedStream) | Returns the byte array representation of the Stream data.
ToString (inherited from EnhancedStream) | Returns the string representation of the Stream data.
Write | Overloaded. Writes data to the stream while applying Telnet-specific formatting.
Write (inherited from EnhancedStream) | Overloaded. When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
WriteByte (inherited from Stream) | Writes a byte to the current position in the stream and advances the position within the stream by one byte.
WriteTo (inherited from EnhancedStream) | Overloaded. Writes all of the data contained in this Stream to a destination Stream.

Explicit Interface Implementations

IDisposable.Dispose (inherited from Stream)

See Also

TelnetStream Class | Dart.PowerTCP.Telnet Namespace


Read Method

PowerTCP Telnet for .NET

TelnetStream.Read Method

Read data from the stream while applying Telnet-specific formatting.

Overload List

Inherited from EnhancedStream.

public int Read(byte[]);

Read data from the stream while applying Telnet-specific formatting.

public override int Read(byte[],int,int);

See Also

TelnetStream Class | Dart.PowerTCP.Telnet Namespace


TelnetStream.Read Method (Byte[], Int32, Int32)

Read data from the stream while applying Telnet-specific formatting.

[Visual Basic]
Overrides Overloads Public Function Read( _
ByVal buffer As Byte(), _
ByVal offset As Integer, _
ByVal count As Integer _
) As Integer
[C#]
public override int Read(
byte[] buffer,
int offset,
int count
);

Parameters

buffer
Destination memory location to store received data.
offset
Starting offset within buffer for filling.
count
Maximum number of bytes to receive.

Return Value

The number of bytes read.

Remarks

This method reads data from the TelnetStream. While data is read, Telnet-specific formatting is applied. For example all CR/NULL sequences are converted simply to CR (if Telnet.TransmitBinary is false). If this method detects a command is received, the TelnetStream.CommandReceived event (and subsequently the Telnet.CommandReceived event) is raised. Use of Telnet.Receive calls this method behind the scenes. If option negotiation has not occurred, using this method causes option negotiaion to initiate.

Exceptions

Exception Type | Condition
IOException | The stream is not Readable.
ArgumentNullException | buffer is null.
ArgumentOutOfRangeException | offset or size is less than 0.
ArgumentException | offset + size is greater than the length of buffer.
SocketException | The socket is not connected.

See Also

TelnetStream Class | Dart.PowerTCP.Telnet Namespace | TelnetStream.Read Overload List


TelnetStream.Refresh Method

Performs option negotiation for any option that has not yet been sent.

[Visual Basic]
Public Sub Refresh()
[C#]
public void Refresh();

Remarks

This method performs option negotiation for any non-negotiated option. Essentially, requests for all Option objects with Option.State = OptionState.RequestOff or OptionState.RequestOn are sent to the server. The Telnet control automatically calls this method when connecting and sending/receiving data to initialize option negotiation.

See Also

TelnetStream Class | Dart.PowerTCP.Telnet Namespace


TelnetStream.Reset Method

Returns all OptionState to their original setting when added to the collection.

[Visual Basic]
Public Sub Reset()
[C#]
public void Reset();

Remarks

This method returns the value of each Option.State property to the original value when it was added to the collection. This is called internally by the Telnet component whenever the connection is closed.

See Also

TelnetStream Class | Dart.PowerTCP.Telnet Namespace


TelnetStream.SendCommand Method

Send a Telnet control function.

[Visual Basic]
Public Function SendCommand( _
ByVal command As Command _
) As Segment
[C#]
public Segment SendCommand(
Command command
);

Parameters

command
The Command to send to the server.

Return Value

A Segment object encapsulating the bytes sent.

Remarks

Telnet control functions are commands which represent functions that are implemented on most servers. For example, most servers provide a function that allows the user to interrupt or abort a process. This is represented by the Telnet control function "IP". Send the "IP" function to the server to cause the server to invoke the function which interrupts or aborts the process. A list of control functions are accessable in the Command topic. Use the Telnet.SendCommand method to send these control functions to the server.

If you wish to perform your own option negotiation (outside of the Telnet components automatic option negotiation) use the Telnet.SendOption method.

See Also

TelnetStream Class | Dart.PowerTCP.Telnet Namespace


TelnetStream.SendOption Method

Send option data to the remote host.

[Visual Basic]
Public Function SendOption( _
ByVal command As Command, _
ByVal code As OptionCode _
) As Segment
[C#]
public Segment SendOption(
Command command,
OptionCode code
);

Parameters

command
The command to send with the option.
code
The option you would like to negotiate about.

Remarks

Typically, option negotiation occurs automatically when using the Telnet component. Use this method ONLY if you wish to disable the automatic negotiation. To disable the automatic negotiation, you must do the following:

  1. Clear both the Telnet.ClientOptions and Telnet.ServerOptions collections.
  2. Use the Telnet.SendOption method from within the Telnet.CommandReceivedEvent in response to a command from the server.

Once automatic option negotiation had been disabled, you must negotiate all options yourself.

See Also

TelnetStream Class | Dart.PowerTCP.Telnet Namespace


TelnetStream.SendSubOption Method

Send suboption data to the remote host.

[Visual Basic]
Public Function SendSubOption( _
ByVal code As OptionCode, _
ByVal subOption As Byte() _
) As Segment
[C#]
public Segment SendSubOption(
OptionCode code,
byte[] subOption
);

Parameters

code
The option that the suboption is providing additional info for.
subOption
The suboption data itself. Refer to the particular option RFC for formatting info.

Return Value

A Segment object describing the data sent.

Remarks

Typically, suboption data is sent automatically by the Telnet component when a new Option (containing the appropriate suboption data) is added to either the Telnet.ClientOptions or Telnet.ServerOptions collections. Use this method ONLY if you are not using the automatic option negotiation. Please refer to the option RFC for more information about sending suboptions.

See Also

TelnetStream Class | Dart.PowerTCP.Telnet Namespace


Write Method

PowerTCP Telnet for .NET

TelnetStream.Write Method

Writes data to the stream while applying Telnet-specific formatting.

Overload List

Inherited from EnhancedStream.

public void Write(byte[]);

Writes data to the stream while applying Telnet-specific formatting.

public override void Write(byte[],int,int);

See Also

TelnetStream Class | Dart.PowerTCP.Telnet Namespace


TelnetStream.Write Method (Byte[], Int32, Int32)

Writes data to the stream while applying Telnet-specific formatting.

[Visual Basic]
Overrides Overloads Public Sub Write( _
ByVal buffer As Byte(), _
ByVal offset As Integer, _
ByVal count As Integer _
)
[C#]
public override void Write(
byte[] buffer,
int offset,
int count
);

Parameters

buffer
Source memory location for the data to send.
offset
Starting offset within buffer for sending.
count
Number of bytes to send.

Return Value

The number of bytes written.

Remarks

This method writes data to the TelnetStream. While data is written, Telnet-specific formatting is applied. For example, all CR are padded with NULL (if Telnet.TransmitBinary is false). Use of Telnet.Send calls this method behind the scenes.

Exceptions

Exception Type | Condition
ArgumentOutOfRangeException | offset or size is less than 0.
ArgumentException | offset + size is greater than the length of buffer.
SocketException | The socket is not connected.

See Also

TelnetStream Class | Dart.PowerTCP.Telnet Namespace | TelnetStream.Write Overload List


TelnetStream Events

The events of the TelnetStream class are listed below. For a complete list of TelnetStream class members, see the TelnetStream Members topic.

Public Instance Events

ClientOptionChanged | This event is raised when the Option.State of a ClientOption has changed.
CommandReceived | This event is raised when a Telnet command has been received from the server.
ServerOptionChanged | This event is raised when the Option.State of a ServerOption has changed.

See Also

TelnetStream Class | Dart.PowerTCP.Telnet Namespace


TelnetStream.ClientOptionChanged Event

This event is raised when the Option.State of a ClientOption has changed.

[Visual Basic]
Public Event ClientOptionChanged As OptionEventHandler
[C#]
public event OptionEventHandler ClientOptionChanged;

Event Data

The event handler receives an argument of type OptionEventArgs containing data related to this event. The following OptionEventArgs property provides information specific to this event.

Property | Description
Option | Represents the option that has changed in an OptionChanged event.

Remarks

A OptionEventArgs object is passed into the event handler, containing information to handle the option change. For example, the OptionEventArgs.Option property contains the option that changed.

This event is useful for determining if option negotiation is complete and the result of the negotiation for a particular option.

See Also

TelnetStream Class | Dart.PowerTCP.Telnet Namespace


TelnetStream.CommandReceived Event

This event is raised when a Telnet command has been received from the server.

[Visual Basic]
Public Event CommandReceived As CommandEventHandler
[C#]
public event CommandEventHandler CommandReceived;

Event Data

The event handler receives an argument of type CommandEventArgs containing data related to this event. The following CommandEventArgs properties provide information specific to this event.

Property | Description
Command | Represents the command sent by the remote host.
OptionCode | Represents the option to which the command pertains.
SubOption | Contains the suboption data.

Remarks

A CommandEventArgs object is passed into the event handler, containing information required to handle the command. For example, the CommandEventArgs.Command property contains the Command sent from the server.

If any reply is sent to the server from within the Telnet.CommandReceived event by using the Telnet.SendOption method, it is assumed that option negotiation will be handled by the developer and automatic option negotion is turned off.

See Also

TelnetStream Class | Dart.PowerTCP.Telnet Namespace


TelnetStream.ServerOptionChanged Event

This event is raised when the Option.State of a ServerOption has changed.

[Visual Basic]
Public Event ServerOptionChanged As OptionEventHandler
[C#]
public event OptionEventHandler ServerOptionChanged;

Event Data

The event handler receives an argument of type OptionEventArgs containing data related to this event. The following OptionEventArgs property provides information specific to this event.

Property | Description
Option | Represents the option that has changed in an OptionChanged event.

Remarks

A OptionEventArgs object is passed into the event handler, containing information to handle the option change. For example, the OptionEventArgs.Option property contains the option that changed.

This event is useful for determining if option negotiation is complete and the result of the negotiation for a particular option.

See Also

TelnetStream Class | Dart.PowerTCP.Telnet Namespace


Samples

The following samples are full application which demonstrate usage of PowerTCP Telnet for .NET. The default directory for sample applications is C:\Program Files\PowerTCP\Telnet for .NET\Samples (where the install drive letter is C:\).

The following table shows the samples for this release and their default install locations.

Sample | Language | Location
Telnet Client Sample | VB.NET Windows Application C# Windows Application | C:\Program Files\PowerTCP\Telnet for .NET\Samples\VB.NET\TelnetClient C:\Program Files\PowerTCP\Telnet for .NET\Samples\C#\TelnetClient
Rlogin Client Sample | VB.NET Windows Application C# Windows Application | C:\Program Files\PowerTCP\Telnet for .NET\Samples\VB.NET\RloginClient C:\Program Files\PowerTCP\Telnet for .NET\Samples\C#\RloginClient
Rexec Sample | VB.NET Windows Application C# Web Application | C:\Program Files\PowerTCP\Telnet for .NET\Samples\VB.NET\Rexec C:\Program Files\PowerTCP\Telnet for .NET\Samples\ASP.NET\Rexec
Rsh Sample | VB.NET Windows Application C# Web Application | C:\Program Files\PowerTCP\Telnet for .NET\Samples\VB.NET\Rsh C:\Program Files\PowerTCP\Telnet for .NET\Samples\ASP.NET\Rsh
Autologin Sample | VB.NET Web Application | C:\Program Files\PowerTCP\Telnet for .NET\Samples\ASP.NET\Autologin

Related Sections

Getting Started
Provides an overview of PowerTCP Telnet for .NET and discusses such topics as distribution, licensing, and support.
Using PowerTCP Within Visual Studio .NET
Demonstrates how to create a project and add a PowerTCP component.
Using The Telnet And Remote Access Components
Demonstrates how to use the Telnet, Rlogin, Rexec, and Rsh components.
Using Events In PowerTCP
Discusses the methodology behind the event implementation for PowerTCP Telnet for .NET, including step-by-step tutorials for implementing your own events.
Reference
Provides a language/syntax reference for PowerTCP Telnet for .NET

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Telnet Client Sample

The Telnet Client Sample demonstrates a fully working client which can be used to connect to, communicate with, and test Telnet server applications. Autologin is also demonstrated with this sample. This sample is available as a Windows Application for both VB.NET and C#.

Requirements

Components: Dart.PowerTCP.Telnet.dll

Location

C:\Program Files\PowerTCP\Telnet for .NET\Samples\VB.NET\TelnetClient

--or--

C:\Program Files\PowerTCP\Telnet for .NET\Samples\C#\TelnetClient

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Rlogin Client Sample

The Rlogin Client Sample demonstrates a fully working client which can be used to log into and communicate with remote hosts. This sample is available as a Windows Application for both VB.NET and C#.

Requirements

Components: Dart.PowerTCP.Telnet.dll

Location

C:\Program Files\PowerTCP\Telnet for .NET\Samples\VB.NET\RloginClient

--or--

C:\Program Files\PowerTCP\Telnet for .NET\Samples\C#\RloginClient

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Rexec Sample

The Rexec Sample demonstrates using the Rexec component to execute a command on a remote host. This sample is available as a Windows Application for both VB.NET and C#.

Requirements

Components: Dart.PowerTCP.Telnet.dll

Location

C:\Program Files\PowerTCP\Telnet for .NET\Samples\VB.NET\Rexec

--or--

C:\Program Files\PowerTCP\Telnet for .NET\Samples\C#\Rexec

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Rsh Sample

The Rsh Sample demonstrates using the Rsh component to execute a command on a remote host. This sample is available as a Windows Application for both VB.NET and C#.

Requirements

Components: Dart.PowerTCP.Telnet.dll

Location

C:\Program Files\PowerTCP\Telnet for .NET\Samples\VB.NET\Rsh

--or--

C:\Program Files\PowerTCP\Telnet for .NET\Samples\C#\Rsh

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


Autologin Sample

The Autologin Sample demonstrates using the Telnet component in the ASP.NET environment. The Telnet component is used to automatically log in to a remote host, execute a command, and log out.

Requirements

Components: Dart.PowerTCP.Telnet.dll

Location

C:\Program Files\PowerTCP\Telnet for .NET\Samples\ASP.NET\Autologin

See Also

Using Telnet for .NET | Telnet for .NET Reference

Send comments on this topic.

© 2002 Dart Communications. All rights reserved.


(global)

PowerTCP Telnet for .NET

(global) Namespace

Classes

Class | Description
BusyException | Thrown whenever a method is called to perform an operation when an operation is already in progress.


BusyException Class

Thrown whenever a method is called to perform an operation when an operation is already in progress.

For a list of all members of this type, see BusyException Members.

System.Object
Exception
ApplicationException
BusyException

[Visual Basic]
Public Class BusyException
Inherits ApplicationException
[C#]
public class BusyException : ApplicationException

Remarks

This exception is thrown if a method is called to perform an upper-layer protocol operation when an operation is already in progress. To keep this exception from being thrown, check the object.Busy property to see if an operation is already in progress.

Requirements

Namespace: (global)

Assembly: Dart.PowerTCP.Telnet (in Dart.PowerTCP.Telnet.dll)

See Also

BusyException Members | (global) Namespace


BusyException Constructor

Initializes a new instance of the BusyException class.

Overload List

Initializes a new instance of the BusyException class.

public BusyException();

Initializes a new instance of the BusyException class.

public BusyException(string);

Initializes a new instance of the BusyException class.

public BusyException(string,Exception);

See Also

BusyException Class | (global) Namespace


BusyException Constructor ()

Initializes a new instance of the BusyException class.

[Visual Basic]
Overloads Public Sub New()
[C#]
public BusyException();

See Also

BusyException Class | (global) Namespace | BusyException Constructor Overload List


BusyException Constructor (String)

Initializes a new instance of the BusyException class.

[Visual Basic]
Overloads Public Sub New( _
ByVal message As String _
)
[C#]
public BusyException(
string message
);

See Also

BusyException Class | (global) Namespace | BusyException Constructor Overload List


BusyException Constructor (String, Exception)

Initializes a new instance of the BusyException class.

[Visual Basic]
Overloads Public Sub New( _
ByVal message As String, _
ByVal e As Exception _
)
[C#]
public BusyException(
string message,
Exception e
);

See Also

BusyException Class | (global) Namespace | BusyException Constructor Overload List


BusyException Members

BusyException overview

Public Instance Constructors

BusyException Overloaded. Initializes a new instance of the BusyException class.

Public Instance Properties

HelpLink (inherited from Exception) | Gets or sets a link to the help file associated with this exception.
InnerException (inherited from Exception) | Gets the Exception instance that caused the current exception.
Message (inherited from Exception) | Gets a message that describes the current exception.
Source (inherited from Exception) | Gets or sets the name of the application or the object that causes the error.
StackTrace (inherited from Exception) | Gets a string representation of the frames on the call stack at the time the current exception was thrown.
TargetSite (inherited from Exception) | Gets the method that throws the current exception.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetBaseException (inherited from Exception) | When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetObjectData (inherited from Exception) | When overridden in a derived class, sets the SerializationInfo with information about the exception.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Exception) | Creates and returns a string representation of the current exception.

See Also

BusyException Class | (global) Namespace


Dispose Method

PowerTCP Telnet for .NET

EnhancedStream.Dispose Method

Releases all resources associated with the object.

Overload List

Releases all resources associated with the object.

public void Dispose();

Releases all resources associated with the object.

public void Dispose(bool);

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace


EnhancedStream.Dispose Method ()

Releases all resources associated with the object.

[Visual Basic]
NotOverridable Overloads Public Sub Dispose() Implements _
IDisposable.Dispose
[C#]
public void Dispose();

Implements

IDisposable.Dispose

Remarks

The Object.Dispose method abruptly aborts the connection and releases all resources.

Object.Dispose should ONLY be used to release all resources used by the object, and the object should not be used subsequently. If an abort is desired, then Object.Close or Object.Connection.Close if available should be used to terminate activity and reset the object. The Object cannot be used once Object.Dispose() or Object.Dispose(true) are called.

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace | EnhancedStream.Dispose Overload List


EnhancedStream.Dispose Method (Boolean)

Releases all resources associated with the object.

[Visual Basic]
Overloads Public Sub Dispose( _
ByVal disposing As Boolean _
)
[C#]
public void Dispose(
bool disposing
);

Remarks

The Object.Dispose method abruptly aborts the connection and releases all resources.

Object.Dispose should ONLY be used to release all resources used by the object, and the object should not be used subsequently. If an abort is desired, then Object.Close or Object.Connection.Close if available should be used to terminate activity and reset the object. The Object cannot be used once Object.Dispose() or Object.Dispose(true) are called.

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace | EnhancedStream.Dispose Overload List


EnhancedStream.Encoding Property

Gets or sets the type of encoding to use.

[Visual Basic]
Public Property Encoding As Encoding
[C#]
public System.Text.Encoding Encoding {get; set;}

See Also

EnhancedStream Class | Dart.PowerTCP.Telnet Namespace


Rexec.SynchronizingObject Property

[Visual Basic]
Public Property SynchronizingObject As ISynchronizeInvoke
[C#]
public System.ComponentModel.ISynchronizeInvoke SynchronizingObject {get; set;}

See Also

Rexec Class | Dart.PowerTCP.Telnet Namespace


Rsh.SynchronizingObject Property

[Visual Basic]
Public Property SynchronizingObject As ISynchronizeInvoke
[C#]
public System.ComponentModel.ISynchronizeInvoke SynchronizingObject {get; set;}

See Also

Rsh Class | Dart.PowerTCP.Telnet Namespace


SegmentedStream.Read Method (Byte[], Byte[], Boolean)

Read data from the stream until a delimiter is reached.

[Visual Basic]
Overloads Public Function Read( _
ByVal buffer As Byte(), _
ByVal delimiter As Byte(), _
ByRef found As Boolean _
) As Integer
[C#]
public int Read(
byte[] buffer,
byte[] delimiter,
ref bool found
);

Parameters

buffer
The storage location for the received data.
delimiter
The token that is used to determine a segment was read.
found
True if delimiter is found; false otherwise.

Return Value

The total number of bytes read into the buffer, which will normally be less than buffer.length. Returns 0 if end of stream is reached and there is no data left to return.

Remarks

This method reads from the stream and returns when the provided delimiter is found, buffer.length bytes have been read, or end of stream is reached.

The purpose of this method is to provide a convenient way to read a variable-length record from the stream. This is the only kind of Read that uses internal buffering.

Exceptions

Exception Type | Condition
IOException | Thrown when the stream is not readable.
ArgumentNullException | Thrown when the receiving buffer is null.
ArgumentOutOfRangeException | Thrown when the offset is less than zero or when count is less than or equal to zero.
ArgumentException | Thrown when (offset + count) > buffer.Length.
EndOfStreamException | At least one byte was read without finding the delimiter before end of stream was reached.

See Also

SegmentedStream Class | Dart.PowerTCP.Telnet Namespace | SegmentedStream.Read Overload List


Tcp.SynchronizingObject Property

Set this object to automatically control thread marshalling between worker threads and the main UI thread.

[Visual Basic]
Public Property SynchronizingObject As ISynchronizeInvoke
[C#]
public System.ComponentModel.ISynchronizeInvoke SynchronizingObject {get; set;}

Property Value

If used, the main UI thread object; null if unused.

Remarks

Any application that (1) uses multithreading (for example, an application which uses an asynchronous BeginXXX method) and (2) must update a shared UI element on the main UI thread (such as a ListView object) from one of these worker threads must set this property to the value of the main UI thread object. If the application meets both of these requirements and this property is NOT set, you may see strange behavior in your application (such as strange exceptions or improper UI element values).

If you do not know whether or not you need to use this property, simply take the failsafe approach when programming Windows applications and always set this property to the Main Form object. If any thread marshalling has to occur between a worker thread and the UI thread, it will occur automatically.

NOTE for server implementations: If you are using a PowerTCP server component to build a server application, you do not want to set this property (as it will cause the server application to become single-threaded). Instead, you want to use the Control.BeginInvoke method to thread-marshall to the main UI thread (see any of the installed sample server applications for an example of this).

See Also

Tcp Class | Dart.PowerTCP.Telnet Namespace


TelnetStream.Close Method

Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream.

[Visual Basic]
Overrides Public Sub Close()
[C#]
public override void Close();

See Also

TelnetStream Class | Dart.PowerTCP.Telnet Namespace