PowerTCP Mail for .NET
Connect(String,Int32,String,Int32) Method
See Also  Example Send comments on this topic.
Dart.PowerTCP.Mail Namespace > Tcp Class > Connect Method : Connect(String,Int32,String,Int32) Method




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.
Connect to a host, specifying the local interface to use.

Syntax

Visual Basic (Declaration) 
<DescriptionAttribute("Connect to a server using a specific interface and port.")>
Public Overloads Sub Connect( _
   ByVal server As String, _
   ByVal serverPort As Integer, _
   ByVal client As String, _
   ByVal clientPort As Integer _
) 
Visual Basic (Usage)Copy Code
Dim instance As Tcp
Dim server As String
Dim serverPort As Integer
Dim client As String
Dim clientPort As Integer
 
instance.Connect(server, serverPort, client, clientPort)
C# 
[DescriptionAttribute("Connect to a server using a specific interface and port.")]
public void Connect( 
   string server,
   int serverPort,
   string client,
   int clientPort
)
Managed Extensions for C++ 
[DescriptionAttribute("Connect to a server using a specific interface and port.")]
public: void Connect( 
   string* server,
   int serverPort,
   string* client,
   int clientPort
) 
C++/CLI 
[DescriptionAttribute("Connect to a server using a specific interface and port.")]
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.

Example

The following example demonstrates connecting to a server while specifying a local interface to use.
Visual BasicCopy Code
' 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#Copy Code
// 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());

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.

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

Documentation Version 3.2
© 2010 Dart Communications. All Rights Reserved.