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

server
Remote hostname or address in dot notation.
serverPort
Remote port, a number between 1 and 65535, inclusive.
See Also Languages PowerTCP SSL Sockets for .NET

Connect(String,Int32) Method

Dart.PowerTCP.SslSockets Namespace > Tcp Class > Connect Method : Connect(String,Int32) Method

Connect to a host.

[Visual Basic]
<DescriptionAttribute("Connect to a server.")> Overloads Public Sub Connect( _    ByVal server As String, _    ByVal serverPort As Integer _ )
[C#]
[DescriptionAttribute("Connect to a server.")] public void Connect(    string server,    int serverPort );
[C++]
[DescriptionAttribute("Connect to a server.")] public: void Connect(    string* server,    int serverPort )
[C++/CLI]
[DescriptionAttribute("Connect to a server.")] 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 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 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

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.