Tag: available

C#

Wait for server to become available

If you are using TcpClient to connect to a Tcp server and you are dealing with Server connections problems but you’d like to allow your TcpClient to connect when the Server becomes available try the following code: while (!client.Connected) { try { client.Connect(server_address, server_listening_port); } catch (Exception) { Thread.Sleep(1000); } }while (!client.Connected) { try { …

C#

Obtain devices list with SharpPcap

SharpPcap is a cross-platform packet capture framework for the .NET environment, based on the famous pcap / WinPcap libraries. It provides an API for capturing, injecting, analyzing and building packets using any .NET language such as C# and VB.NET.   CaptureDeviceList cdevices = CaptureDeviceList.Instance; if (cdevices.Count >= 1) { foreach (ICaptureDevice dev in cdevices) { …