Dart.PowerTCP.EmailValidation 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
System.MarshalByRefObject
System.ComponentModel.Component
Dart.PowerTCP.EmailValidation.Tcp
Dart.PowerTCP.EmailValidation.SmtpTester
[Visual Basic]
<ToolboxItemAttribute(ToolboxItemType=, ToolboxItemTypeName="")>
<DescriptionAttribute("The Tcp Component integrates event handling, Stream support, and a concise TCP model")>
Public Class Tcp
Inherits Component
[C#]
[ToolboxItemAttribute(ToolboxItemType=, ToolboxItemTypeName="")]
[DescriptionAttribute("The Tcp Component integrates event handling, Stream support, and a concise TCP model")]
public class Tcp : Component
[C++]
[ToolboxItemAttribute(ToolboxItemType=, ToolboxItemTypeName="")]
[DescriptionAttribute("The Tcp Component integrates event handling, Stream support, and a concise TCP model")]
public __gc class Tcp : public Component
[C++/CLI]
[ToolboxItemAttribute(ToolboxItemType=, ToolboxItemTypeName="")]
[DescriptionAttribute("The Tcp Component integrates event handling, Stream support, and a concise TCP model")]
public ref class Tcp : public Component
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.
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.
The following example demonstrates blocking operations using the Tcp component.
[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 Echo Server
Tcp1.Connect("myEchoServer", 7)
' Send some data
Tcp1.Send("Hello Server!" + vbCrLf)
' Get response from the server
Dim seg As Segment = Tcp1.Receive()
Debug.WriteLine(seg.ToString())
' Send more data
Tcp1.Send("You are a swell host" + vbCrLf)
' Get response from the server
seg = Tcp1.Receive()
Debug.WriteLine(seg.ToString())
'Close the connection
Tcp1.Close()
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 Echo Server
tcp1.Connect("myEchoServer", 7);
// Send some data
tcp1.Send("Hello Server!\r\n");
// Get response from the server
Segment seg = tcp1.Receive();
Debug.WriteLine(seg.ToString());
// Send more data
tcp1.Send("You are a swell host\r\n");
// Get response from the server
seg = tcp1.Receive();
Debug.WriteLine(seg.ToString());
//Close the connection
tcp1.Close();
}
Namespace: Dart.PowerTCP.EmailValidation
Platforms: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP, Windows Server 2003, Windows Vista
Assembly: Dart.PowerTCP.EmailValidation (in Dart.PowerTCP.EmailValidation.dll)
Tcp Members | Dart.PowerTCP.EmailValidation Namespace
Send comments on this topic.
Documentation version 1.0.3.0.
© 2008 Dart Communications. All rights reserved.