TCP Asynchronous Client DLL for C#. Communicate with TCP Server in C# Applications. Simple and less resource usage model without multithreading or waitOne().
Add the DLL to your project as a reference. Create a TCPAsyncClient Object and use the functions. Complete workable example is given in Sample Application
- public AsynchronousClient(string _ip, int _port)
- void Connect() - Connect to the server
- bool Write(string _data) - Send data to server
- bool Write(byte[] _data) - Send data to server
- void Dispose() - Dispose socket/ connection
- void Disconnect() - Disconnect connection
- bool IsConnected() - Check is the socket connected
- Connection Status - OnConnectEventHandler -> void OnConnect(bool status)
- Recieve Data - DataReceivedEventHandler -> void OnRecieved(string data)
AsynchronousClient tcp = new AsynchronousClient(txtIpAddress.Text, int.Parse(txtPort.Text));
tcp.OnConnectEvent += new AsynchronousClient.OnConnectEventHandler(OnConnect);
tcp.OnDataRecievedEvent += new AsynchronousClient.DataReceivedEventHandler(OnRecieved);
tcp.Connect();
private void OnConnect(bool status)
{
Console.WriteLine("Connection Status : " + status.ToString());
}
private void OnRecieved(string data)
{
Console.WriteLine("Recieved Data : " + data);
}
private void WriteData(string data)
{
try
{
if (tcp.Write(data))
{
Console.WriteLine("Write OK");
}
else
{
Console.WriteLine("Write Failed");
}
}catch(Exception ex)
{
// Catch errors in Sending Data
Console.WriteLine("Error : " + ex.ToString());
}
}
You can use Hercules Setup Utility to create TCP server in Local Machine with few clicks. Here is an example.
This application is developed using .NET Framework 4.6
Please go to release page to download the stable version. We recommend not to use alpha or beta releases for your projects.
Contributors are WELCOME!
The MIT License (MIT). Please see License File for more information.