S
S
Senture2020-12-22 17:49:47
C++ / C#
Senture, 2020-12-22 17:49:47

UDP Multicast Receiving data from the server without delay?

Good day!
The situation is the following.
Sending data by multicast:

socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            IPAddress ip = IPAddress.Parse(GlobalData.Address);
            socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(ip));
            socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, GlobalData.TTL);
            IPEndPoint endPoint = new IPEndPoint(ip, GlobalData.Port);
            socket.Connect(endPoint);
socket.Send(_byte, _byte.Length, SocketFlags.None);


Client code:
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            endPoint = new IPEndPoint(IPAddress.Any, GlobalData.Port);
            socket.Bind(endPoint);

            address = IPAddress.Parse(GlobalData.Address);
            socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership,
                new MulticastOption(address, IPAddress.Any));

while(true)
{
....
socket.Receive(b);
....
Thread.Sleep(1000);
}


The server sends data every 100ms, the client receives data every 1000ms. Since the client does not have time (on purpose) for the data from the server while the client is sleeping, the server will send 10 messages, and when the client starts receiving data again, it will receive not 11 messages from the server but 1 (i.e. the next after the last received) , and I need the client to skip those 10 messages after sleep that the server sent while the client was in hibernation.

Please tell me in which direction should I dig?
UDP, Multicast and Sleep (on the client) are required.

PS Thank you all very much!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Korotenko, 2020-12-22
@Senture

UDP does not guarantee delivery. What has come has come.
And you already operate with the receive buffer. Perhaps you should add the send time and insert missed packets.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question