Mike G
Mike G

Reputation: 4959

Should I have a delay between sending packets?

I have an application that is sending UDP packets to a receiver, should I have a delay between each packet being sent, to avoid overwhelming the receiver, if I do, how do I set the delay time?

note: I am sending a text file over an unreliable network.

        for(int x = 0; x < len; x++)
        {
                send_msg(packet);
                Thread.sleep(200); //Should I have this?   
        }

Upvotes: 0

Views: 530

Answers (1)

jdevelop
jdevelop

Reputation: 12296

Let the OS to handle timings for you. Sending is blocking, so it will rely on OS buffers and related thing. PAckets will be either delivered to serer or lost, but as soon as they are delivered - then the peer will be notified. It may postpone processing or put packets to the queue.

Upvotes: 1

Related Questions