Skip to content

Quick Start

samgerene edited this page Oct 3, 2026 · 3 revisions

Quick Start

This guide walks you through setting up a minimal ArgusTransfer server with a route module and a client that sends requests to it.

Prerequisites

  • .NET 10.0 SDK or later
  • Windows, Linux or macOS. Named pipes are a Windows IPC mechanism; on Linux and macOS, .NET maps them to Unix domain sockets. ArgusTransfer is tested on Windows and Linux; pipe ACLs (PipeSecurity) apply to Windows only.

1. Create a New Project

dotnet new console -n MyArgusService
cd MyArgusService

Add the ArgusTransfer package and the .NET generic host:

dotnet add package ArgusTransfer
dotnet add package Microsoft.Extensions.Hosting

2. Define a Module

Create a module that registers a simple GET endpoint:

using System.Threading.Tasks;

using ArgusTransfer.Protocol;
using ArgusTransfer.Routing;

public class HelloModule : IArgusModule
{
    public void AddRoutes(IArgusRouteBuilder app)
    {
        app.MapGet("/hello", context =>
        {
            context.Response = new ArgusResponse
            {
                StatusCode = ArgusStatusCode.Ok,
                Body = "Hello from ArgusTransfer!"
            };

            return Task.CompletedTask;
        });
    }
}

3. Configure the Host

Set up the server and client in Program.cs:

using ArgusTransfer.Extensions;
using ArgusTransfer.Routing;

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

Host.CreateDefaultBuilder(args)
    .ConfigureServices(services =>
    {
        services.AddArgusModules();                        // Discovers HelloModule automatically
        services.AddArgusPipeHost(o => o.PipeName = "demo"); // Listen on named pipe "demo"
        services.AddArgusClient("demo");                   // Register a client for the same pipe
        services.AddHostedService<DemoClientService>();     // Run the client demo
    })
    .Build()
    .Run();

4. Create a Client Service

Create a background service that sends a request to the server:

using System;
using System.Threading;
using System.Threading.Tasks;

using ArgusTransfer.Client;

using Microsoft.Extensions.Hosting;

public class DemoClientService : BackgroundService
{
    private readonly IArgusClient client;
    private readonly IHostApplicationLifetime lifetime;

    public DemoClientService(IArgusClient client, IHostApplicationLifetime lifetime)
    {
        this.client = client;
        this.lifetime = lifetime;
    }

    protected override async Task ExecuteAsync(CancellationToken stoppingToken)
    {
        await Task.Delay(1000, stoppingToken); // Wait for server to start

        var response = await this.client.GetAsync("/hello", cancellationToken: stoppingToken);

        Console.WriteLine($"Status: {(int)response.StatusCode} {response.StatusCode}");
        Console.WriteLine($"Body: {response.Body}");

        this.lifetime.StopApplication();
    }
}

5. Run It

dotnet run

Expected output:

Status: 200 Ok
Body: Hello from ArgusTransfer!

Next Steps

Clone this wiki locally