I use Socket
to receive data from udp multicast. The code is trivial:
s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); .... while (true) { int count = 0; try { count = socket.Receive(byteArray); } catch (Exception e) { Console.WriteLine(e.Message); return; } if (count > 0) { OnNewMessage(new NewMessageEventArgs(byteArray, count)); } }
The problem is that sometimes I lose packets. Not too often, ~ once every 2 minutes.
I am sure that the package was received because I see it in another C ++ program running on the same computer and configured to receive the same packages.
Why can't my program catch packages that others can use? Why am I losing packages? Is it possible that the computer is too slow (or too busy) to receive packets?
I get about 2,000 packets per second and using the Xeon E3 processor, which should be more than what I think ...
source share