PowerTCP Sockets for .NET

from $349.00
Available Platforms

Server, Tcp, Udp, Dns, Ping Components

PowerTCP Sockets for .NET is an enhanced collection of sockets controls, boasting a newly designed API that is intuitive and easy to use. The new design promotes a Model-View-Controller (MVC) application architecture, so that you may localize your protocol functions and settings to a reusable model class. This library requires fewer resources, provides greater flexibility, elicits code that is easier to re-use and maintain, and is backed by the best technical support in the industry.

  • Supports .NET 2.0 features including generics, IPv6, and X509 certificates
  • Supports .NET 4.5 Asynchronous Tasks for TCP and UDP.
  • Secure Socket Layer (SSL) security
  • Transport Layer Security (TLS)
  • Lightweight, Single Dll typically less than 5% the size of our competitors' bloated dlls
  • Powerful, scalable Server control
  • Many code examples and sample applications in C# and VB

 

Consulting and Custom Development

From custom protocols to complete client-server solutions, let our experienced staff help with your TCP/IP project.

 

Feature-Rich Components

  • Stream interface enhances ease of integration
  • TLS & SSL support makes secure communications as easy as a single method call
  • SOCKS4, SOCKS5, Http proxy support included
  • Log event simplifies debugging and logging
  • New IPEndPoint class resolves IPv4 and IPv6 hostnames
  • Support for Windows applications, services, console and ASP.NET web applications

 

Scalable Multithreaded Server

  • Build high-performance server apps that implement any TCP-based protocol
  • Dedicate a worker thread to each connection or make asynchronous reads using scalable IO completion threads
  • Client connections are enumerated in a convenient list

 

Ping, DNS and UDP

  • UDP component builds on Framework capabilities
  • MX Record look-up (for resolving mail server names) supplements native DNS class
  • Resolve host names, IPv4, and IPv6 addresses using a specified DNS server and local endpoint
  • Ping includes broadcasting capabilities
  • Ping without admin permissions
  • Trace routes to discover bottlenecks

 

Samples and Documentation

  • Many sample projects for C# and VB.NET, including ASP.NET
  • Comprehensive MS Help 2.0 and Help Viewer integrated documentation
  • Stand-alone and online documentation
  • .NET Framework 4 Client Profile compatible
  • 64-bit OS support
     

Sockets for .NET Includes

Five components plus supporting classes
Sample projects written in C#, VB.NET, VC++/CLI
Comprehensive MS Help 2.0 and MS Help Viewer integrated documentation
Free introductory support

Component Description
Ping Component Ping hosts to determine availability.
Server Component Create scalable server applications using TCP and optionally TLS\SSL
Tcp Component Communicate with servers using TCP and optionally TLS\SSL.
Udp Component Communicate with hosts using UDP.
Dns Component Resolve host names and addresses, as well as mail hosts associated with email addresses.

  

Supported Environments

PowerTCP for .NET components and classes will operate on any Microsoft operating system that fully supports the Microsoft .NET Framework, including 64-bit Windows. .NET components are dependent on the Framework rather than a specific operating system. Products support .NET Framework versions 2.0, 3.0, 3.5, 4.0, 4.5, 4.6, 4.7, .NET Standard 2.0, and .NET Core 2.0. The components can be used with any .NET compliant language, including the following languages:

 

  • C#
  • VB.NET
  • Managed C++
  • PowerShell

 

PowerTCP for .NET components have been tested in the following application environments:

 

  • Standard Windows desktop applications
  • Console applications
  • ASP.NET web applications and Web Sites
  • Windows service applications
  • Web service applications
  • Windows .NET Framework 4 Client Profile

 

PowerTCP for .NET components have been tested in the following development environments:

 

  • Visual Studio .NET (2005, 2008, 2010, 2012, 2013, 2015, 2017)

 

PowerTCP for .NET components have been tested with the following proxies:

 

  • Ositis WinProxy 6.1 R1c
  • Handcrafted Software FreeProxy 4.10.1751
  • Fiddler2

 

 

PowerTCP for .NET components do not currently support execution within Silverlight. If you are interested in using Dart products within your Silverlight solution, contact support@dart.com for more options.

 

Code Examples

These code snippets can be copied and pasted into your project.

 

Code Snippet Description
Tcp Echo Client Demonstrates how to connect, send and receive data in a windows forms application.
Worker Thread Server Demonstrates how to write a server that dedicates a worker thread for each client.
Async Server Demonstrates how to write a server that utilizes on-demand IO completion threads.
UDP Multicast Demonstrates how to join a multicast group asynchronously, without blocking the UI.
Ping Remote Host Demonstrates how to ping a remote host asynchronously, without blocking the UI.
DNS Mail Host Lookup Demonstrates how lookup mail hosts associated with an email address asynchronously, without blocking the UI.

 

Sample Projects

Samples are working applications demonstrating Sockets for .NET components in C#, VB.NET and C++/CLI. Source code included.

 

Sample Name Sample Description
DNS Client Demonstrates a client used for resolving domain names, IP addresses and mail address hosts.
Ping Client Demonstrates a client used for determining if a host is reachable
Proxy Server Implements a test proxy server that supports SSL tunneling, as well as Socks and Http proxy servers.
Server Server implements several protocols with two modes of operation ("sync" using dedicated worker threads and "async" using IO completion threads).
Server Windows Service Demonstrates a server that runs as a windows service.
Simple Server Uses the PowerTCP Sockets Server class to demonstrate an echo server with a minimal amount of code.
TCP Client Demonstrates a client which communicates with hosts using TCP with optional proxy and SSL use.
TCP Client Task Async Uses awaitable task methods to communicate with hosts using TCP with optional proxy and SSL use.
Trace Route Client Demonstrates a client that traces a route to any host.
UDP Chat Client Uses UDP multicasting or broadcasting to chat with other users on the network.
UDP Chat Client Uses UDP multicasting or broadcasting to chat with other users on the network.
UDP Chat Client Task Async Uses the awaitable task methods of the UDP class to demonstrate multicasting or broadcasting to chat with other users on the network.
UDP Time Demonstrates Network Time Protocol (NTP) over UDP on both client- and server-side.
Ping Web Client Demonstrates a web page that can be used to ping other hosts.
TCP Echo Web Client Uses the Tcp component in ASP.NET to communicate with an echo server.

 

 

Product Release History

The following is a list of public releases for all components shipped with PowerTCP Sockets for .NET (Latest Release 2018-04-30)

 

PowerTCP Sockets for .NET

Current Version: 4.5.4.0

 

4.5.4.0    Released: 2018-04-30

 

    • Added support for .NET Standard 2.0 and .NET Core 2.0
    • New .NET Core 2.0 sample projects, referencing the Dart.Sockets.Standard dll
    • Updated trial license operation for use on .NET Standard-compatible platforms
      • Details regarding trial operation for Dart.Sockets.Standard.dll can be found in the Licensing and Trial Operation topic in the included help documentation

     

    4.5.3.0   Released: 2017-03-08


     

    • Visual Studio 2017 compatibility.

     

     

    4.5.2.0 Released: 2016-10-18


     

    Product fixes in this release:

    • An issue where requesting less bytes than what is available when reading asynchronously and using ssl could potentially result in hangs until another socket operation is performed has been resolved. (692)
    • ClientSecurity.TargetHost will now use Session.RemoteEndPoint.HostNameOrAddress if TargetHost is not populated per current documentation. (712)
    • IPv6 Ping reply addresses are now reported correctly. (950)

     

     

    4.5.1.1   Released: 2014-12-05


     

    Product fixes in this release:

    • An issue where the server component would intermittently fail to post another pending accept if a failure occurred during a previous accept has been resolved. (593)

     

     

    4.5.0.1   Released: 2014-06-05


     

    • Support for IPV6 address resolution added to the DNS component.
    • Added awaitable read, write, and connect method overloads to the TCP and UDP classes. Developers must use the Dart.Sockets.45 dll in order to take advantage of this functionality.
    • Added a ConnectTimeout property to the TCP Session class to provide a time out for pending connections.
    • Improved support for CAS level 2 applications in medium trust environments.

     

     

    4.4.4.8   Released: 2012-10-26


     

    • PowerTCP Sockets for .NET has been updated for Visual Studio 2012 integration and Windows 8 compatibility.
    • Trial licensing operation updated.
    • Changed serialization to use simple partial name serialization to improve cross-version compatibility.

     

    Product fixes in this release:

    • A more informative exception is now thrown when AuthenticateAsServer is called and the connection is aborted before authentication can succeed. (5411)
    • Addressed a globalization issue that prevented correct operation for systems using the following language cultures: Azeri (az), Azeri-Latin (az-Latn), Azeri-Latin-Azerbaijan (az-Latn-AZ), Turkish (tr), Turkish-Turkey (tr-TR). (TFS31)

     

     

    4.4.3.1   Released: 2012-07-12


     

    Product fixes in this release:
    Fixed a licensing issue with web service applications.
    Updated the title bar of licensing messages to not indicate a product is in trial when it is licensed.

     

     

    4.4.2.0   Released: 2012-06-27


     

    • Updated trial operation behavior and removed obstacle to using product in .NET Framework 4.5.

     

     

    4.4.1.3   Released: 2012-04-24


     

    Product fixes in this release:

    • Fixed memory leak in Server component. (5595)

     

     

    4.4.0.3   Released: 2011-03-03


     

    • The Mx Class has been replaced with a Dns component. In addition to performing Mx record lookups, the component performs domain name and IP address lookups. Features include the ability to specify the local endpoint to bind to, as well as the DNS server to use.
    • Many custom Start delegates such as TcpThreadStart and UdpThreadStart have been replaced with the .NET Framework standard WaitCallback delegate. This generally means that callback functions no longer include the calling component as a parameter (this is true even for custom delegates that were not replaced).
    • The Connect method was updated to take the new TcpSession object as a parameter. TcpSession is a serializable object that facilitates the saving of session settings.
    • The AuthenticateAsClient and AuthenticateAsServer methods were updated to take the new ClientSecurity and ServerSecurity objects as parameters, respectively. These two objects are serializable, facilitating the saving of security sessions.
    • The ReadToX functions (ReadtoDelimiter, ReadToCount, ReadToEnd) were updated to throw the new DataException when an error condition occurs. DataException includes a DataRead field which provides the data read prior to the exception.
    • Several samples were updated with "model" classes, to fall more in line with the Model-View-Controller (MVC) design philosophy. For more on MVC, see the "MVC Design in Applications" page of the help file.

     

    Product fixes in this release:

    • Addressed a memory leak with the ReceiveAsync call. (5396)
    • The ConnectionStateChanged event and the ConnectionState property now indicate a closed state when the remote host forcibly closes a connection. (5401)
    • Tcp.Close no longer causes a ConnectionReset exception. (5406)

     

     

    4.3.0.6   Released: 2011-01-07


     

    Dart Communications is pleased to announce the release of PowerTCP Sockets for .NET 4.3. Some of the features include:

    • Model-View-Controller design uses fewer resources, is more flexible, and produces code that is easier to maintain
    • Improved Use of .NET Features including generics and IPv6
    • SSL support for secure communications
    • SOCKS4, SOCKS5, HttpConnect proxy with design editor support
    • Multithreaded Server component for sophisticated server apps using any TCP-based protocol
    • Dedicate a worker thread to each connection, or
    • Use asynchronous read calls utilizing IO completion threads
    • UDP builds on inherent Framework capabilities
    • Perform MX Record look-ups
    • Ping includes a broadcasting option
    • Ping without the need of admin permissions using system dlls
    • Trace routes to discover bottlenecks
    • Support for Windows applications, services and ASP.NET web applications
    • Many sample projects for C#, VB.NET, C++/CLI, including ASP.NET
    • Comprehensive MS Help 2.0 and Help Viewer 1.0 integrated documentation
    • Stand-alone and online documentation also provided
    • NET Framework 4 Client Profile compatible
    • 64-bit OS support

     

    No more Async methods

    Previous versions of PowerTCP and PowerSNMP implemented an event-driven model for asynchronous use. In addition to a synchronous method, each operation had an asynchronous "BeginXXX" method and corresponding "EndXXX" event. For example, to receive data asynchronously using the Tcp component, the developer called BeginReceive and waited for the EndReceive event to fire with data. In the meantime, other code was free to execute.

    In the new model, asynchronous methods have been eliminated. Instead, the developer uses one or more synchronous methods (for example, "Receive") within a straight blocking function, and then passes a delegate referring to this function to the component's Start method. The Start method then executes the function on its own worker thread.

     

    Marshaling data back to the UI thread
    It is often necessary to pass information from a worker thread to an element on the UI thread. The new model includes Marshal functions to simplify these cross-thread operations. Each Marshal overload corresponds to an event handler that executes on the UI thread and provides access to data passed using the Marshal method.

     

    No more "pseudo-blocking"
    Methods in the new model are now true-blocking calls. In previous versions, methods were "pseudo-blocking," meaning that events could be raised while the call blocked. With the new model, the UI is blocked if a method is called from within the UI thread. The Start method should therefore be used in UI environments so that events are raised.

     

    Slaves
    Some components, such as Ping, make use of child Slave objects to perform blocking operations. The parent component defines events and includes properties that apply to all slaves.

     

    Use of IPEndPoints
    Many methods in the current model include overloads that take IPEndPoint parameters, to facilitate IPv6 use. A new IPEndPoint derived class provides several overloads for easy IPEndPoint creation, including automatic hostname resolution.

     

     

    1.1.1.0   Released: 2008-01-30


     

    Product fixes in this release:

    • Fixed problem with CryptDecrypt sample.

     

     

    1.1.0.3   Released: 2008-01-16


     

    • New Tcp.WaitFor method for continuous receiving of data until a token string (or one of several token strings) is found.
    • New Dns.Servers collection for specifying multiple possible DNS servers to try.
    • Sockets now supports 64 bit environments.
    • Ping and TraceRoute now offer greater time precision.
    • An Abort method has been added to Ping.
    • Server.Listen has a new overload with an IPEndPoint parameter.

     

    Product fixes in this release:

    • SegmentedStream.Read overloads with a "found" parameter now have EndRead method counterparts for examining the value of "found." (2931)
    • The connection is no longer aborted in VS.NET 2005 after a Receive timeout. (4146)
    • Ping results no longer contain an extra 40 bytes of null data. (4232)

     

    Ping .NET Component

    Use the Ping component to integrate Ping functionality into any .NET application. Easily check if a host is reachable by sending and receiving ICMP packets. Features include:

     

    • Easy-to-use GetEchoes method sends a ping to a host
    • Specify optional data, sequence number, and TTL
    • Start method provides easy to implement operation on a worker thread
    • Send many requests simultaneously using multiple instances of the PingSlave class
    • Trace routes; responses include data for each hop
    • Includes "Type.System" option which does not require permission to utilize raw sockets
    • Includes option to broadcast pings using raw sockets
    • Marshal methods handle data marshaling to the UI thread
    • Integrates with versions 2005, 2008, 2010 and 2012 of Visual Studio
    • Supports C#, VB.NET, C++/CLI, ASP.NET and other .NET compliant development environments
    • Includes a royalty-free license!

     

    See the complete PowerTCP Sockets for .NET Online Documentation >

     

    Looking for the ActiveX version of this component?

    Server .NET Component

    Use the Server component to quickly build any custom TCP server application. Features include:

     

    • Easily build a server implementing TCP-based protocols such as FTP, SMTP, POP, etc
    • Write a custom protocol server
    • Stream interface enables advanced read/write capabilities such as reading to a delimiter
    • SSL support for secure communication
    • Dedicate a worker thread for each connection for streamlined, state-less code
    • Alternatively use asynchronous read calls for a high performance server utilizing IO completion threads
    • Log event exposes data sent and received for easy debugging and logging
    • Support for popular proxies, including Socks and HttpConnect
    • Underlying properties of utilized sockets exposed
    • Integrates with versions 2005, 2008, 2010 and 2012 of Visual Studio
    • Supports C#, VB.NET, C++/CLI, ASP.NET and other .NET compliant development environments
    • Includes a royalty-free license!

     

    See the complete PowerTCP Sockets for .NET Online Documentation >

     

    Looking for the ActiveX version of this component?

    Tcp .NET Component

    Use the Tcp component to communicate with any host using TCP (Transmission Control Protocol). Features include:

     

    • Stream interface enables advanced read/write capabilities such as reading to a delimiter
    • SSL support for secure communication
    • Log event exposes data sent and received for easy debugging and logging
    • Start method provides easy to implement operation on a worker thread
    • Asynchronous socket reads also supported
    • Marshal methods handle data marshaling to the UI thread
    • Support for popular proxies, including Socks and HttpConnect
    • PTY property binds a TextBox to the component as a ready-made interface for interactive online communications
    • Underlying properties of the utilized socket exposed
    • Provides asynchronous awaitable connect, read, write, and authenticate operations.
    • Integrates with versions 2005, 2008, 2010 and 2012 of Visual Studio
    • Supports C#, VB.NET, C++/CLI, ASP.NET and other .NET compliant development environments
    • Includes a royalty-free license!

     

    See the complete PowerTCP Sockets for .NET Online Documentation >

     

    Looking for the ActiveX version of this component?

    Udp .NET Component

    Use the Udp component within the .NET Framework to send and receive user datagrams. Features include:

     

    • Simple, intuitive Send and Receive methods handle all communication
    • JoinMulticastGroup and LeaveMulticastGroup makes managing multicasting easy
    • Start method provides easy to implement operation on a worker thread
    • Marshal methods handle data marshaling to the UI thread
    • Underlying properties of the utilized socket exposed
    • Provides asynchronous awaitable read and write operations.
    • Integrates with versions 2005, 2008, 2010 and 2012 of Visual Studio
    • Supports C#, VB.NET, C++/CLI, ASP.NET and other .NET compliant development environments
    • Includes a royalty-free license!

     

    See the complete PowerTCP Sockets for .NET Online Documentation >

     

    Looking for the ActiveX version of this component?

    Dns .NET Component

    Use the Dns component to integrate domain name resolution functionality into any .NET application, allowing your application to easily resolve domain names, host addresses, and email addresses. Features include:

     

    • The Dns component bypasses Winsock system services, so you can query ANY Domain Name Server on the Internet.
    • Resolves a host name to a dot address (forward lookup) and resolves a dot address to a host name (reverse lookup).
    • Resolves an email address to the mail server(s) responsible for the email address. Not supported in the .NET Framework!
    • Supports IPv6.
    • Permits selection of the local address to bind to.
    • C# and VB.NET sample projects included.
    • Includes a royalty-free license!

     

    Looking for the ActiveX version of this component?

    Windows Forms TCP Code Example

    The following example demonstrates a simple TCP session in a Windows Forms environment. The client sends data to an echo server and receives it back. The session is executed asynchronously, without blocking the UI.

     

    private void buttonStart_Click(object sender, EventArgs e)
    {
        //This application has a User-Interface, which we do not want to block.
        //Start launches the specified method on a worker thread.
        //Event handlers execute on the UI thread.
        tcp1.Start(connect, "myEchoServer");
    }

    private void connect(object host)
    {
        //This function connects to an echo server and receives echoed data.
        //The Start method is used to execute this function on a worker thread.
        tcp1.Connect(new TcpSession(new Dart.Sockets.IPEndPoint(host.ToString(), 7)));

        //Marshals data to the UI as it is received.
        byte [] buffer = new byte[1024];
        while (tcp1.State == Dart.Sockets.ConnectionState.Connected)
            tcp1.Marshal(tcp1.Read(buffer), ""null);
    }

    private void textInterface_KeyPress(object sender, KeyPressEventArgs e)
    {
        //The last line entered in the textbox is sent to the server.
        //The app closes down when 'exit' is entered.
        if (e.KeyChar == 13)
        {
            string lastLine = textInterface.Lines[textInterface.Lines.Count() - 1];
            if (lastLine.ToLower() == "exit") tcp1.Close();
            else tcp1.Write(lastLine);
        }
    }
    void tcp1_Data(object sender, Dart.Sockets.DataEventArgs e)
    {
        //This event is raised on the UI when data is marshaled from a worker thread.
        //Displays the received data in the textbox.
        if (e.Data != null)
            textInterface.AppendText("> " + e.Data.ToString() + Environment.NewLine);
    }

    private void tcp1_StateChanged(object sender, EventArgs e)
    {
        //This event is raised when the Tcp component changes state.
        textInterface.Enabled = (tcp1.State == Dart.Sockets.ConnectionState.Connected);
        if (tcp1.State == Dart.Sockets.ConnectionState.Connected)
        {
            textInterface.Clear();
            textInterface.Focus();
        }
    }

    Server Using Worker Threads Code Example

    The following example demonstrates an Echo Server in a Windows Forms environment. Each client is processed on a dedicated worker thread.

     

    private void buttonStart_Click(object sender, EventArgs e)
    {
        //Start the echo server on port 7.
        //Each client is processed on its own worker thread.
        server1.Start(new ConnectThreadStart(acceptConnection), 7, null);
    }

    private void acceptConnection(TcpBase connection, object state)
    {
        //While connection is open, echo data received back to the client.
        //This function executes on a worker thread.
        byte[] buffer = new byte[1024];
        do
        {
            Data data = connection.Read(buffer);
            if (data != null)
                connection.Write(data.Buffer, data.Offset, data.Count);
        } while (connection.State == Dart.Sockets.ConnectionState.Connected);
    }

    private void buttonStop_Click(object sender, EventArgs e)
    {
        //Gracefully stop the echo server.
        server1.Close();
    }

    Async Server Code Example

    The following example demonstrates an Echo Server in a Windows Forms environment. The server uses on-demand IO completion threads to handle clients.

     

    private void buttonStart_Click(object sender, EventArgs e)
    {
        //Start the echo server on port 7.
        server1.Start(new ConnectThreadStart(acceptConnection), 7, null);
    }

    private void acceptConnection(TcpBase connection, object state)
    {
        //This function executes on a worker thread.
        //An async Read is posted. The readAsyncCompleted callback will
        //execute when data is available.
        byte[] buffer = new byte[1024];
        connection.ReadAsync(buffer, 0, buffer.Length,
            new ReadAsyncCompleted(readAsyncCompleted), null);
    }

    private void readAsyncCompleted(TcpBase connection, Data data, object state)
    {
        //This function executes when data has been read.
        //Echo data received back to the client and post an async Read.
        if (data != null)
        {
            connection.Write(data.Buffer, data.Offset, data.Count);
            connection.ReadAsync(data.Buffer, 0, data.Buffer.Length,
            new ReadAsyncCompleted(readAsyncCompleted), null);
        }
    }

    private void buttonStop_Click(object sender, EventArgs e)
    {
        //Gracefully stop the echo server.
        server1.Close();
    }

    Windows Forms UDP Multicast Code Example

    The following example demonstrates a UDP session in a Windows Forms environment. The app joins a multicast group, sends a message, receives a response and leaves. The session is executed asynchronously, without blocking the UI.

     

    private void buttonHello_Click(object sender, EventArgs e)
    {
        //This application has a User-Interface, which we do not want to block.
        //Start launches the specified method on a worker thread.
        udp1.Start(sendHello, new Dart.Sockets.IPEndPoint("234.5.6.7", 59877));
    }

    private void sendHello(object groupEP)
    {
        //Join a multicast group, send a message, receive a response, and leave.
        //The group endpoint is passed into the function.
        Dart.Sockets.IPEndPoint ep = (Dart.Sockets.IPEndPoint)groupEP;

        //Join Multicast group.
        udp1.Open(ep.Port);
        udp1.JoinMulticastGroup(ep.Address);

        //Send message.
        udp1.Send("hello world", ep);

        //Receive response.
        byte[] buffer = new byte[1024];
        udp1.Receive(buffer);

        //Leave group.
        udp1.LeaveMulticastGroup(ep.Address);
    }

    Windows Forms Ping Code Example

    The following example demonstrates a ping operation in a Windows Forms environment. The operation is executed asynchronously, without blocking the UI.

     

    private void buttonPing_Click(object sender, EventArgs e)
    {
        //This application has a User-Interface, which we do not want to block.
        //Start launches the specified method on a worker thread.
        ping1.Start(ping, new Dart.Sockets.IPEndPoint("www.dart.com", 0).Address);
    }

    private void ping(PingSlave slave, object address)
    {
        //Ping the passed in address and marshal the results to the UI.
        //The ping contains no optional data, a 20 hop TTL and a 5 second timeout.
        //This function executes on a worker thread.
        ping1.Marshal(slave.GetEchoes((System.Net.IPAddress)address, null, 20, 5000, false));
    }

    private void ping1_Echo(object sender, EchoEventArgs e)
    {
        //This event is raised when a GetEchoes result is passed to the UI.
        string results = "The following echoes were returned:\r\n";
        for (int i = 0; i < e.Echoes.Length; i++)
            results += e.Echoes[i].ToString() + "\r\n";
        MessageBox.Show(results);
    }

    Windows Forms DNS MX Lookup Code Example

    The following example demonstrates a DNS operation in a Windows Forms environment. The application retrieves mail hosts for a specified email address. The session is executed asynchronously, without blocking the UI.

     

    private void buttonLookup_Click(object sender, EventArgs e)
    {
        //This application has a User-Interface, which we do not want to block.
        //Start launches the specified method on a worker thread.
        dns1.Start(new DnsThreadStart(doLookup), "myAddress@gmail.com");
    }

    private void doLookup(DnsSlave slave, object address)
    {
        //Lookup mail servers associated with the passed in address.
        MxHostEntry[] servers = slave.GetMxHostEntries(address.ToString(), dns1.Servers[0]);

        //Build a string from the results and marshal it to the UI thread via the UserState event.
        string results = "The following mail servers were returned:\r\n";
        for (int i = 0; i < servers.Length; i++)
             results += servers[i].HostName + " (" + servers[i].Preference.ToString() + ")\r\n";
        dns1.Marshal(results, null);
    }

    private void dns1_UserState(object sender, UserStateEventArgs e)
    {
        //This event is raised on the UI thread
        //when DNS results are marshaled from a worker thread.
        MessageBox.Show(e.Message);
    }

    Purchase Options

    Customize your product and support options match your needs. Discounts are applied when products are purchased in multiples or within available product suites.

    $0.00 discount
     
    $499.00

    Have any questions about purchasing? See our Sales FAQ