See Also

Tcp Class  | Tcp Members  | Overload List

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Language

Visual Basic

C#

C++

C++/CLI

Show All

buffer
Data to be decoded into bytes and sent.
See Also Languages PowerTCP SSL Sockets for .NET

Send(String) Method

Dart.PowerTCP.SslSockets Namespace > Tcp Class > Send Method : Send(String) Method

Send data to the server.

[Visual Basic]
<DescriptionAttribute("Converts a string into a byte array and sends it.")> Overloads Public Function Send( _    ByVal buffer As String _ ) As Segment
[C#]
[DescriptionAttribute("Converts a string into a byte array and sends it.")] public Segment Send(    string buffer );
[C++]
[DescriptionAttribute("Converts a string into a byte array and sends it.")] public: Segment* Send(    string* buffer )
[C++/CLI]
[DescriptionAttribute("Converts a string into a byte array and sends it.")] public: Segment^ Send(    String^ buffer )

Parameters

buffer
Data to be decoded into bytes and sent.

Return Type

A Segment object encapsulating information about the data sent.

Exceptions

ExceptionDescription
ArgumentOutOfRangeExceptionoffset or count is less than 0.
ArgumentExceptionoffset + count is greater than the length of buffer.
SocketExceptionThe socket is not connected.

Remarks

After connecting, data can be received using the Send method. All 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.

Example

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();
}
                

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Tcp Class  | Tcp Members  | Overload List


Send comments on this topic.

Documentation version 1.1.2.0.

© 2008 Dart Communications.  All rights reserved.