You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Asynchronous TCP client with automatic reconnection, message queuing, and thread-safe operation.
✨ Features
Feature
Description
🔄 Auto-Reconnect
Automatically re-establishes connections with a 3-second retry on failure
📦 Message Queuing
Incoming data is queued (FIFO, up to 100 messages) for reliable retrieval
🔒 Thread-Safe
All operations are protected with locking for concurrent access
⚡ Fully Async
Uses BeginConnect / BeginRead / BeginWrite for non-blocking I/O
🔔 Event-Driven
Rich event model for connection changes, data arrival, and errors
🎛️ Enable/Disable
Pause and resume communication without destroying the connection
📦 Installation
dotnet add package ThreeByte.LinkLib.TcpLink
or via the NuGet Package Manager:
Install-Package ThreeByte.LinkLib.TcpLink
🚀 Quick Start
usingThreeByte.LinkLib.TcpLink;// Create a TCP link to a remote devicevartcp=newAsyncTcpLink("192.168.1.100",5000);// Subscribe to eventstcp.IsConnectedChanged+=(s,connected)=>Console.WriteLine(connected?"✅ Connected":"❌ Disconnected");tcp.DataReceived+=(s,e)=>Console.WriteLine($"Data arrived: {tcp.GetMessage()?.Length} bytes");tcp.ErrorOccurred+=(s,ex)=>Console.WriteLine($"Error: {ex.Message}");// Send a messagebyte[]command=System.Text.Encoding.ASCII.GetBytes("HELLO\r\n");tcp.SendMessage(command);// Retrieve queued incoming dataif(tcp.HasData){byte[]?response=tcp.GetMessage();}// Clean uptcp.Dispose();