#include	<stdio.h>
#include	"actived.h"
#include	"protocol.h"


int main(argc, argv)
int argc;
char *argv[];
{
	int s, i;
	int start = time(NULL) - 1;
	struct wireprotocol buffer;

	if ((s = create_udp_socket(0)) < 0) {
		fprintf(stderr, "couldnt create socket\n");
		exit(1);
	}
	if (connect_udp_socket(s, "localhost", 1119) < 0) {
		fprintf(stderr, "couldnt connect socket\n");
		exit(1);
	}
	i = 0;
	fprintf(stderr, "%08d", 0);
	for (;;) {
		buffer.RequestType = REQ_FIND;
		sprintf(buffer.Name, "alt.sex");
		if (write_udp(s, (char *)&buffer, sizeof(buffer)) < 0) {
			fprintf(stderr, "couldnt write packet\n");
			exit(1);
		}
		if (read_udp(s, (char *)&buffer, sizeof(buffer)) != sizeof(buffer)) {
			fprintf(stderr, "couldnt read packet\n");
			exit(1);
		}
		if (! (++i % 100)) {
			fprintf(stderr, "\r%08d %5.2f", i, (float)i / (time(NULL) - start));
		}
	}
}




