/** * This code creates N threads. Each threads does one GET to an address. The * GET, the address and the number of threads are passed as argument. An "\r\n" * is appended to the GET string. */ /* headers *//*{{{*/ #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/socket.h> #include <sys/types.h> #include <pthread.h> #include <netinet/in.h> #include <netinet/ip.h> #include <netdb.h>/*}}}*/
/* declarations and prototypes */ /*{{{*/ #define pexit(s) ({perror(s); exit(exit_failure);}) static struct cstats { int socket_errors; int send_errors; int recv_errors; int connect_errors; int avg_respt; /* average response time */ pthread_mutex_t mutex; } cstats;
struct sockaddr_in addr;
#define buflen 1024 static char buf[buflen]; static int buf_len;
void *get_get_thread(void *);/*}}}*/
int main(int argc, char **argv) { /* main declarations *//*{{{*/ int i; int fail = 0; int ngets; int addr_len; int error; struct hostent *host; pthread_t *threadv; pthread_attr_t attr;/*}}}*/
/* error checking *//*{{{*/ if (argc <= 4) { printf("usage: %s address port number_of_gets get_string\n", argv[0]); exit(exit_failure); }