FreeBSD/libexec/tftpd/tftp-file.c
/* When an error has occurred, it is possible that the two sides
 * are out of synch.  Ie: that what I think is the other side's
 * response to packet N is really their response to packet N-1.
 *
 * So, to try to prevent that, we flush all the input queued up
 * for us on the network connection on our host.
 *
 * We return the number of packets we flushed (mostly for reporting
 * when trace is active).
 */
When an error has occurred, it is possible that the two sides
are out of synch.  Ie: that what I think is the other side's
response to packet N is really their response to packet N-1.

So, to try to prevent that, we flush all the input queued up
for us on the network connection on our host.

We return the number of packets we flushed (mostly for reporting
when trace is active).
When an error has occurred it is possible that the two sides are out of synch . Ie : that what I think is the other side ' s response to packet N is really their response to packet N - 1 . So to try to prevent that we flush all the input queued up for us on the network connection on our host . We return the number of packets we flushed ( mostly for reporting when trace is active ) .
int
synchnet(int peer)			
{
	int i, j = 0;
	char rbuf[MAXPKTSIZE];
	struct sockaddr_storage from;
	socklen_t fromlen;
	while (1) {
		(void) ioctl(peer, FIONREAD, &i);
		if (i) {
			j++;
			fromlen = sizeof from;
			(void) recvfrom(peer, rbuf, sizeof (rbuf), 0,
				(struct sockaddr *)&from, &fromlen);
		} else {
			return(j);
		}
	}
}
int synchnet ( int peer ) { int i , j = 0 ; char rbuf [ MAXPKTSIZE ] ; struct sockaddr_storage from ; socklen_t fromlen ; while ( 1 ) { ( void ) ioctl ( peer , FIONREAD , & i ) ; if ( i ) { j ++ ; fromlen = sizeof from ; ( void ) recvfrom ( peer , rbuf , sizeof ( rbuf ) , 0 , ( struct sockaddr * ) & from , & fromlen ) ; } else { return ( j ) ; } } }
When an error has occurred, it is possible that the two sides
 are out of synch.
When an error has occurred it is possible that the two sides are out of synch .
/* socket to flush */