I'm doing some quality measurements on an Internet connection and I'm having some timing problems. My code are as follows:
Server:
Code:
printf("\nMeasuring Download:\n");
q=0;
timeout=0;
tsendbuffer = sendbuffer;
while(1){
	sendto(sock, tsendbuffer, 256,0,(struct sockaddr *)&from,sockaddrlength);
	tsendbuffer = tsendbuffer + 256;
	q++;
	if(q == sendbuffsize){
		printf("sending stop packets, q = %d\n",q);
		sendto(sock, &stoppacket, 1, 0,(struct sockaddr*)&from 
									,sockaddrlength);
		do{
			timeout=0;
			while (((n = recvfrom(sock, &receivebuffer,1,0, 
					(struct sockaddr *)&from ,&sockaddrlength))==-1)
					 && (++timeout < retry)){
				perror("down-stop");
				printf("Timeout #%d of %d, trying again:\n", 
									timeout,retry);
				sendto(sock, &stoppacket, 1, 0,
						(struct sockaddr *)&from,sockaddrlength);
				printf("sending stop packets\n");
			}
			if(n<0){ 
				perror("recvmax");
				break;
			}
						
		}while(receivebuffer[0]!='A');
		break;
	}
}
Client:
Code:
while(1){
    data->timeout = 0;
    while ((timeoutvar=recv(data->sock, receivebuffer,256,0))==-1){
	    perror("recv");
	    printf("Timeout #%d of %d, trying again:\n", data->timeout,data->retry);
		if (++data->timeout < data->retry){
			printf("Transfer Rate function timeout!\n");
			return -1;
		}

	    }
	    if( receivebuffer[0] == stoppacket[0]){
		printf("stop pkg rec.\n");
		printf("ko = %d\n",ko);
		break;
	    }
	    ko++;
	}
So the server is sending data until q reaches sendbuffsize. This happens when q is equal to around 32000. The client will receive those packets and increment ko every time it receives one, however when ko is printed it is only between 32 and 21000.

How can i ensure that all packets arrive at the client side?

It seems to have an influence whether or not it is the fastest computer that is the client.

Many thanks in advance!
FusionFox