+ do {
+ alarm(rexmtval);
+ do
+ n = recvfrom(f, buf, sizeof (buf), 0,
+ (caddr_t)&from, &fromlen);
+ while (n <= 0);
+ alarm(0);
+ if (n < 0) {
+ perror("tftp: recvfrom");
+ goto abort;
+ }
+ if (trace)
+ tpacket("received", tp, n);
+ /* should verify client address */
+ tp->th_opcode = ntohs(tp->th_opcode);
+ tp->th_block = ntohs(tp->th_block);
+ if (tp->th_opcode == ERROR) {
+ printf("Error code %d: %s\n", tp->th_code,
+ tp->th_msg);
+ goto abort;
+ }
+ } while (tp->th_opcode != DATA && block != tp->th_block);