I profiled some boilerplate UDP code and the speed was very good for sending only some small amount data (which is my intent).
BUT the "connect" method is "very slow" compared to the "send" method.
This takes 50 - 80 ms:
udpClient = new UdpClient();
udpClient.Connect("HOSTNAME", 11000);
Sending is then hardly profiled by 1 ms, because its so amazing fast:
Byte[] sendBytes = Encoding.ASCII.GetBytes("Is anybody there?");
udpClient.Send(sendBytes, sendBytes.Length);
I wonder what this "connect" method does, since UDP is connectionless by design.
If I leave out the connect method, then send is slower per call:
udpClient.Send(sendBytes, sendBytes.Length,"HOSTNAME",1100);
Any chance to improve the "connect" speed?
Disclaimer: I know UDP is unreliable, but for my app (client statistics, which are not 100% exact anyway) it doesn't matter if packages come in wrong order and even some lost packages don't kill me.