ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
i have to generate traffic over a wireless network by sending random numbers over the network for about,say 10 minutes.What i dont understand is how to time the generation of random numbers to a particular value.
I am doing the programming in C and trying to use the rand() function.
Distribution: Ubuntu 7.04, LFS 6.3 rc1 (living dangerously ;), Windows XP
Posts: 75
Rep:
I don't quite understand what you mean by "how to time the generation of random numbers to a particular value". Do you mean, how to loop over the random-number-sending bit for 10 minutes? Something like this would work...
Code:
#include <sys/types.h>
#include <time.h>
int main()
{
int num_seconds = 600;
time_t starttime;
time_t endtime;
time(&starttime);
time(&endtime);
while(endtime <= starttime + num_seconds)
{
//do your numbersending here
time(&endtime);
}
return 0;
}
hey...
thnx for the code...
there's another problem that i'm facing with the sending of random numbers to generate traffic,which is,where do i edit the program for the client.
I'm using the following program for the client :
this program uses "fgets", which asks for input from the user.but i want to use rand() to generate random numbers and send them over to the server. how do i do that?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.