I am trying to create a multi-threading application that'll try and send a lot of data to a specific IP and port using sockets in C#. I have completed this, but I need help in getting more information from it.
I would like to know how I could get how much data is being sent a second? In MB if possible, from all threads and all requests?
I am mearly doing this for educational purposes to see how much data can actually be sent and how it all works when doing it with multi -threading
Here is my code:
static void Main(string[] args)
{
int amountOfThreads = 10;
while (amountOfThreads > 0)
{
Thread thread = new Thread(SendData);
thread.Start();
}
}
private static void SendData()
{
byte[] dataToSend = Encoding.Default.GetBytes("some string that'll be sent many times.");
string ipAddress = "127.0.0.1";
int port = 3924;
IPEndPoint ep = new IPEndPoint(IPAddress.Parse(ipAddress), port);
Socket socketToSendTo = new Socket(System.Net.Sockets.AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
socketToSendTo.SendTo(dataToSend, ep);
}