OutWit.Communication.Client.Tcp 2.1.0

dotnet add package OutWit.Communication.Client.Tcp --version 2.1.0
                    
NuGet\Install-Package OutWit.Communication.Client.Tcp -Version 2.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OutWit.Communication.Client.Tcp" Version="2.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OutWit.Communication.Client.Tcp" Version="2.1.0" />
                    
Directory.Packages.props
<PackageReference Include="OutWit.Communication.Client.Tcp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OutWit.Communication.Client.Tcp --version 2.1.0
                    
#r "nuget: OutWit.Communication.Client.Tcp, 2.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OutWit.Communication.Client.Tcp@2.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OutWit.Communication.Client.Tcp&version=2.1.0
                    
Install as a Cake Addin
#tool nuget:?package=OutWit.Communication.Client.Tcp&version=2.1.0
                    
Install as a Cake Tool

OutWit.Communication.Client.Tcp

TCP transport client for WitRPC, enabling network communication over TCP sockets (with optional TLS support) to connect to WitRPC servers.

Overview

OutWit.Communication.Client.Tcp enables a WitRPC client to communicate with a server over TCP/IP. This transport is ideal for distributed systems that require communication across network boundaries or over the internet. TCP is a low-level, robust transport that provides reliable, ordered delivery of data, making it suitable for large-scale applications and services. With this client, you can connect to a WitRPC server listening on a specific host and port.

Key points:

  • Network Communication: Unlike named pipes or memory-mapped files (which are for local IPC), TCP works across machines. You provide the server's hostname or IP address and port, and the client will connect to that endpoint over the network.

  • Optional TLS Security: This client supports secure connections via TLS. WitRPC provides WithTcpSecure methods to handle the SSL/TLS handshake. When using TLS, the server must have an X.509 certificate and the client will validate it. This allows you to securely communicate with a server over the internet. (You can use WitRPC's own encryption on top of TLS as well, but typically if using TLS, you might disable the additional layer of encryption to avoid double-encrypting.)

  • High Performance: TCP has minimal overhead and is suitable for high-throughput and low-latency communication. The WitRPC protocol runs efficiently on top of TCP, allowing multiple requests and responses to be handled concurrently over the single connection.

As with all transport-specific packages, OutWit.Communication.Client.Tcp should be used with the matching server package OutWit.Communication.Server.Tcp on the server side (both client and server must use TCP to communicate).

Installation

Install-Package OutWit.Communication.Client.Tcp

Usage

Configure the TCP endpoint when building the client. For example:

using OutWit.Communication.Client;
using OutWit.Communication.Client.Tcp;
using OutWit.Communication.Serializers;
using OutWit.Communication.Client.Encryption;

var client = WitClientBuilder.Build(options =>
{
    // Connect to server at example.com on port 5001 using TCP:
    options.WithTcp("example.com", 5001);
    options.WithJson();
    options.WithEncryption(); // enable message-level encryption (optional, see below)
    // If server requires a token:
    // options.WithAccessToken("SecureToken");
});
await client.ConnectAsync(TimeSpan.FromSeconds(5));

IMyService service = client.GetService<IMyService>();

In this example, the client opens a TCP connection to example.com:5001. If your server is on the same machine, you could use "localhost" or the machine's local IP address instead of "example.com". The ConnectAsync call attempts to establish the socket connection within 5 seconds.

By default, we called WithEncryption(), which means the WitRPC protocol will encrypt the request/response payloads at the application layer (using AES/RSA). This is useful if you're running over plaintext TCP. If you plan to use TLS at the transport layer, you might omit this (or use WithoutEncryption()).

Using TLS (Secure TCP): If the server is configured with TLS (via WithTcpSecure), the client should also use WithTcpSecure to connect. For example:

options.WithTcpSecure("example.com", 5002, "example.com");
// Where "example.com" is both the host address and the expected certificate name.

This will initiate an SSL/TLS handshake with the server on port 5002. The third parameter is the server's host name for certificate validation (often the same DNS name you used to connect). Optionally, you can provide a custom certificate validation callback if you need to accept self-signed certs or implement custom validation logic. When using WithTcpSecure, consider not using WitRPC's own encryption (WithEncryption()), because the TCP connection itself will be encrypted by TLS.

Authorization: Just like other transports, you can use WithAccessToken on the TCP client to include an authorization token. The server (with OutWit.Communication.Server.Tcp) can then validate this token for each connection or request.

Once connected, you use the service proxy exactly as you would in a local scenario: call methods, await results, handle events. The TCP client will keep the connection open until you dispose the client or an error/timeout occurs. This allows multiple calls to reuse the same connection efficiently.

Firewall Note: Ensure that the port you are connecting to is open on the server's firewall. For instance, if connecting to port 5001, that port must be allowed through any firewall on the server machine and network.

Further Documentation

See the WitRPC documentation for more about TCP transport usage, including details on setting up TLS certificates and best practices for deployment in production environments.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.1.0 29 9/11/2025
2.0.1 77 7/5/2025
2.0.0 79 6/7/2025
1.2.0 116 2/28/2025
1.1.1 117 2/1/2025
1.1.0 112 1/25/2025
1.0.2 120 1/11/2025
1.0.0 134 1/2/2025