RCON client core lib.
$ dotnet add package RCON.NetThe core RCON client library - a lightweight, dependency-free implementation of the RCON protocol.
RCON.Net.Core provides the fundamental building blocks for RCON communication:
Install via NuGet:
dotnet add package RCON.Net
Manages RCON connections and command execution.
var client = new RconClient("127.0.0.1", 25575, "password");
await client.ConnectAsync();
var response = await client.ExecuteAsync("command");
await client.DisconnectAsync();
Fluent API for configuring RCON clients with validation and default values.
var client = RconClientBuilder.Create()
.WithHost("127.0.0.1")
.WithPort(25575)
.WithPassword("your-password")
.WithTimeout(TimeSpan.FromSeconds(5))
.Build();
Configuration Options:
WithHost(string) - Server hostname or IP addressWithPort(int) - Server RCON port (default: 25575)WithPassword(string) - RCON authentication passwordWithTimeout(TimeSpan) - Command execution timeoutBase interface for all command implementations.
public interface ICommand
{
string Build();
T? Parse<T>(string response) where T : class;
}
Commands implement:
Build() - Generates the command string to send to the serverParse<T>() - Parses server response into a typed result objectThe RCON protocol is handled internally:
RconException - Base exception for all RCON-related errorsRconConnectionException - Connection failuresRconAuthenticationException - Authentication failuresRconTimeoutException - Command execution timeoutsusing RCON.Core;
// Create and configure client
var client = RconClientBuilder.Create()
.WithHost("127.0.0.1")
.WithPort(25575)
.WithPassword("admin-password")
.WithTimeout(TimeSpan.FromSeconds(10))
.Build();
try
{
// Connect to server
await client.ConnectAsync();
// Execute raw command
var response = await client.ExecuteAsync("say Hello World");
Console.WriteLine(response);
}
finally
{
await client.DisconnectAsync();
client.Dispose();
}
? No external dependencies
? Async/await support
? Configurable timeouts
? Connection pooling support
? Thread-safe operations
? Comprehensive error handling
For more information about the RCON protocol, see:
MIT License - See LICENSE file for details.