generating random numbers for 10 minutes
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. Cheers, Shubham |
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> |
Moved: This thread is more suitable in Programming and has been moved accordingly to help your question get the exposure it deserves.
|
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 : #include <sys/types.h> #include <sys/socket.h> #include <stdio.h> #include <netinet/in.h> #include <arpa/inet.h> #include <unistd.h> #include <string.h> #include <netdb.h> #include <stdlib.h> #include <errno.h> #include <readline/readline.h> #include <readline/history.h> int main(int argc, char **argv) { int sockfd; struct sockaddr_in servaddr; if (argc != 2){ printf("usage: tcpcli <IPaddress>"); exit(0); } sockfd = socket(AF_INET, SOCK_STREAM, 0); bzero(&servaddr, sizeof(servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_port = htons(1200); inet_pton(AF_INET, argv[1], &servaddr.sin_addr); connect(sockfd, (struct sockaddr *) &servaddr, sizeof(servaddr)); str_cli(stdin, sockfd); /* do it all */ exit(0); } str_cli(FILE *fp, int sockfd) { char sendline[1000], recvline[1000]; while (fgets(sendline, 1000, fp) != NULL) { write(sockfd, sendline, strlen (sendline)); if (read(sockfd, recvline,1000) == 0){ printf("str_cli: server terminated prematurely"); exit(0); } fputs(recvline, stdout); return(0); } } 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? |
Something like
Code:
while (your_condition) |
All times are GMT -5. The time now is 02:24 AM. |