SocketJack 1.2.0
See the version list below for details.
dotnet add package SocketJack --version 1.2.0
NuGet\Install-Package SocketJack -Version 1.2.0
<PackageReference Include="SocketJack" Version="1.2.0" />
<PackageVersion Include="SocketJack" Version="1.2.0" />
<PackageReference Include="SocketJack" />
paket add SocketJack --version 1.2.0
#r "nuget: SocketJack, 1.2.0"
#:package SocketJack@1.2.0
#addin nuget:?package=SocketJack&version=1.2.0
#tool nuget:?package=SocketJack&version=1.2.0
SocketJack
SocketJack is a high-performance, flexible networking library for .NET, designed to simplify the creation of robust client-server and peer-to-peer (P2P) applications. It provides a modern, extensible API for TCP and WebSocket communication, advanced serialization, and seamless P2P networking with metadata-driven peer discovery.
Features
Unified TCP & WebSocket Support
Easily create clients and servers using TCP or WebSockets with a consistent API.Peer-to-Peer (P2P) Networking
Built-in P2P support allows direct peer connections, peer discovery, and metadata sharing.- Peers are identified, discovered, and described using The Identifier class w/metadata.
- Host and client roles are managed automatically.
- Peer redirection and relay are supported for NAT traversal scenarios AND typical centralized configurations.
Advanced Serialization
- Serializer interface (
ISerializer
) with a fast, efficient JSON implementation. - Custom converters for complex types (e.g.,
Bitmap
). - Type whitelisting/blacklisting for secure deserialization.
- Serializer interface (
Efficient Data Handling
- Large buffer support (default 1MB) for high-throughput scenarios.
- Asynchronous, non-blocking I/O for scalability.
- Optimized for .NET Standard 2.1, .NET 6, .NET 8, and .NET 9.
Metadata-Driven Peer Management
- Attach arbitrary metadata to peers and connections.
- Query and filter peers by metadata for dynamic discovery and routing.
Extensible Event System
- Events for connection, disconnection, peer updates, and data receipt.
- Customizable handling for peer redirection and connection requests.
Security & Control
- SSL/TLS support for secure connections.
- Fine-grained control over allowed types and connection policies.
Peer-to-Peer Implementations
SocketJack's P2P system is designed for flexibility and ease of use:
Peer Discovery:
Use metadata to find peers with specific attributes (e.g., game lobbies, chat rooms).Direct Peer Connections:
Peers can connect directly, bypassing the server when possible for low-latency communication.Peer Redirection:
If a direct connection is not possible, messages can be relayed through other peers or the server.Host/Client Role Management:
The library automatically manages which peer acts as host or client, simplifying connection logic.Metadata Propagation:
Metadata changes are propagated to all connected peers, enabling dynamic network topologies.
Efficiency
High Throughput:
Large default buffer sizes and efficient serialization minimize overhead.Asynchronous Operations:
All networking is fully async, allowing thousands of concurrent connections.Minimal Allocations:
Serialization and deserialization are optimized to reduce memory usage and GC pressure.Selective Serialization:
Only allowed types are serialized/deserialized, improving security and performance.
Possible Usages
SocketJack is ideal for a wide range of networking scenarios, including:
Real-Time Multiplayer Games
Fast, low-latency communication between players with dynamic peer discovery.Distributed Chat Applications
Peer-to-peer chat with metadata-driven room discovery and direct messaging.IoT Device Networks
Efficient, secure communication between devices with flexible topology.Remote Control & Automation
Secure, event-driven control of remote systems with custom data types.Custom Protocols & Services
Build your own protocols on top of TCP/WebSocket with full control over serialization and peer management.
Getting Started
- Install via NuGet:
Install-Package SocketJack
- Create a Server:
var server = new TcpServer(port: 12345);
server.StartListening();
- Connect a Client:
var client = new TcpClient();
await client.Connect("127.0.0.1", 12345);
- Sending and Receiving:
client.Send("Hello, Server!");
server.OnReceived += (sender, args) => {
var message = args.Object as string;
// Handle message
};
- Setting up callbacks:
// Register a callback for a custom class
server.RegisterCallback<CustomClass>((peer, customClassObject) =>
{
Console.WriteLine($"Received: customClassObject");
// Echo back to the client
peer.Send("10-4");
});
- Enabling options by default: MUST be called before the instantiation of a Client or Server.
TcpOptions.Default.UsePeerToPeer = true;
- Attach Metadata: This will ONLY work on the server authority. Use your own authentication to validate the clients.
client.Identifier.SetMetaData(client, "Room", "Lobby1");
Documentation
License
SocketJack is open source and licensed under the MIT License.
Contributing
Contributions, bug reports, and feature requests are welcome!
See CONTRIBUTING.md for details.
SocketJack � Fast, flexible, and modern networking for .NET.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. net6.0-windows7.0 is compatible. net7.0 was computed. 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 was computed. 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. net8.0-windows7.0 is compatible. net9.0 was computed. 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Mono.Nat (>= 3.0.4)
- System.Collections.Concurrent (>= 4.3.0)
- System.Text.Json (>= 9.0.7)
-
net6.0-windows7.0
- Mono.Nat (>= 3.0.4)
- System.Collections.Concurrent (>= 4.3.0)
- System.Drawing.Common (>= 9.0.8)
- System.Text.Json (>= 9.0.7)
-
net8.0-windows7.0
- Mono.Nat (>= 3.0.4)
- System.Collections.Concurrent (>= 4.3.0)
- System.Drawing.Common (>= 9.0.8)
- System.Text.Json (>= 9.0.7)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SocketJack:
Package | Downloads |
---|---|
SocketJack.NewtonsoftJson
An Implementation of Newtonsoft.Json for SocketJack |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.2.0.92925 | 0 | 9/29/2025 |
1.2.0 | 117 | 9/24/2025 |
1.1.0.1 | 54 | 8/2/2025 |
1.0.3 | 150 | 7/4/2025 |
1.0.2.60100 | 176 | 6/1/2025 |