See Also

Server Members  | Dart.PowerTCP.SslSockets Namespace

Requirements

Namespace: Dart.PowerTCP.SslSockets

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

Assembly: Dart.PowerTCP.SslSockets (in Dart.PowerTCP.SslSockets.dll)

Language

Visual Basic

C#

C++

C++/CLI

Show All

See Also Requirements Languages PowerTCP SSL Sockets for .NET

Server Class

Dart.PowerTCP.SslSockets Namespace : Server Class (Dart.PowerTCP.SslSockets)

The Server component provides a quick and easy way to build a non-secure or secure server application by managing Tcp connections.

For a list of all members of this type, see Server members.

Object Model


Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         Dart.PowerTCP.SslSockets.Server

Syntax

[Visual Basic]
<LicenseProviderAttribute(ServerLicenseProvider)> Public Class Server    Inherits Component
[C#]
[LicenseProviderAttribute(ServerLicenseProvider)] public class Server : Component
[C++]
[LicenseProviderAttribute(ServerLicenseProvider)] public __gc class Server : public Component
[C++/CLI]
[LicenseProviderAttribute(ServerLicenseProvider)] public ref class Server : public Component

Remarks

Use the Server component to listen for incoming connections. When a connection is established from a TCP client, a new thread is created on which the server and client can communicate.

What follows are short usage descriptions. For more information, see the appropriate member topic

Using the Server Component

Listening for connections: Use the Listen method (specifying the port to listen on) to listen for incoming TCP connections.

Determining if the server is active: Once the server is bound to a port and listening for incoming connections, the ActiveChanged event is raised. Check the Active property to see if this event was raised because the server began listening or stopped listening.

Handling incoming connections: When a TCP client connects to the server, the Connection event is raised. A Tcp instance is made available in the event, representing the connection between client and server. Use the Tcp instance to send and receive data to/from the connected client.

Stop accepting incoming connections: Use the Close method to stop accepting incoming connections. Any existing connections will remain intact.

Stop the server while closing all connections: Use the Abort method to stop the server and immediately close all connections.

Communicating securely (available with PowerTCP SSL Sockets for .NET only!): Set the Certificate property to a valid Certificate object to automatically create an SSL Server.

Example

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 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 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, 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.
        
Segment seg = e.Tcp.Receive();

        
// Echo data back to client.
        
e.Tcp.Send(seg.ToString());
     }
  }
  
catch(Exception ex)
  {
     
// eat any exceptions
  }
}
                

Requirements

Namespace: Dart.PowerTCP.SslSockets

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

Assembly: Dart.PowerTCP.SslSockets (in Dart.PowerTCP.SslSockets.dll)

See Also

Server Members  | Dart.PowerTCP.SslSockets Namespace

 

Send comments on this topic.

Documentation version 1.1.2.0.

© 2008 Dart Communications.  All rights reserved.