C#. UDP unicast -
I try to get six messages from the UDP Unicast client. The recipient looks like this:
OpenCloud udpclient = new instance (); Ipdpoint locale = new ipadpoint (ipadress purse (client ip), clientport); Udpclient.Client.Bind (localEp); Udpclient.Client.ReceiveTimeout = 10000; Bool isTimeExpired = false; While (IsTimeExpired) {Byte [Buffer; Try {buffer = udpclient.Receive (ref localEp); } Hold (socket exception) {isTimeExpired = true; to continue; } // Deserialize // ...} udpclient.Close (); The program works, but sometimes I do not receive 6 messages (2 or 3) Sender application:
UdpClient Client = New UdpClient (); Ipdpoint rimp = new ipdpoint (ipadres percy (client ip), clientport); // serialize // ... stream.page = 0; Byte [] data = new byte [stream. Length]; Stream Read (Data, 0, Convert.ToMnt32 (stream.Length)); Customer Send (Data, Data, Long, Remote); Stream.Close (); Client.Close (); I run 6 instances of sender application on the same machine (and an example of the receiver). I need to get the message from every sender (total six messages) all the time. Where is my fault?
Thanks a lot!
This is a UDP, there is no guarantee that any was not received. UDP is incredible by design. "Users" in UDP can stand for "Incredible" instead. :)
FYI: There is no guarantee that you will receive only one copy of any data sent to you.
If you need such credibility, then you need TDP, not UDP (or you need to do a bunch, there is no guarantee that Datagram will come in the same order. Additional work to re-discover the wheel).
Comments
Post a Comment