I'm programming a simple script in perl that do the following:
- Open a socket to a specific server
- Reads data line by line from a big file using a while loop
- Send data using the open socket
I don't report the whole code since it works perfect and could be too long. What I need to accomplish is send an ammount of packets every seconds. For example I would like to limit to send 100 packets per second. This because the loop is so fast and sometime the server goes in congestion.
What I need, is undestand how (and if) I can implement this kind of mechanism. Is not clear for me how to insert code into the while loop to send "X" packets every second. The actual code looks like:
Open file containing data to send
while # Read file line by line
Send data to Server
Thank you, Lucas.