exercises/ex04/trout/trout.c
void print_report ()
{
  int stat;
  double rtt, krtt;
  char str[NI_MAXHOST];

  stat = sock_cmp_addr (sarecv, salast, salen);

  /* if this reply comes from source different from the previous
     one, print the full host information */

  if (stat != 0) {
    stat = getnameinfo (sarecv, salen, str, sizeof(str), NULL, 0, 0);
    if (stat == 0) {
      printf (" %s (%s)", str, Sock_ntop_host (sarecv, salen));
    } else {
      printf (" %s", Sock_ntop_host (sarecv, salen));
    }
    memcpy (salast, sarecv, salen);
  }

  /* calculate and print the round trip time using user-level timestamps */

  sub_tv (recvtv, sendtv, difftv);
  rtt = time_to_double (difftv);

  printf ("  %.3f", time_to_double (difftv));
}
/* print_report: prints all the information about a successful round trip */
prints all the information about a successful round trip
prints all the information about a successful round trip
void print_report ()
{
  int stat;
  double rtt, krtt;
  char str[NI_MAXHOST];
  stat = sock_cmp_addr (sarecv, salast, salen);
  if (stat != 0) {
    stat = getnameinfo (sarecv, salen, str, sizeof(str), NULL, 0, 0);
    if (stat == 0) {
      printf (" %s (%s)", str, Sock_ntop_host (sarecv, salen));
    } else {
      printf (" %s", Sock_ntop_host (sarecv, salen));
    }
    memcpy (salast, sarecv, salen);
  }
  sub_tv (recvtv, sendtv, difftv);
  rtt = time_to_double (difftv);
  printf ("  %.3f", time_to_double (difftv));
}
void print_report ( ) { int stat ; double rtt , krtt ; char str [ NI_MAXHOST ] ; stat = sock_cmp_addr ( sarecv , salast , salen ) ; if ( stat != 0 ) { stat = getnameinfo ( sarecv , salen , str , sizeof ( str ) , NULL , 0 , 0 ) ; if ( stat == 0 ) { printf ( " " , str , Sock_ntop_host ( sarecv , salen ) ) ; } else { printf ( " " , Sock_ntop_host ( sarecv , salen ) ) ; } memcpy ( salast , sarecv , salen ) ; } sub_tv ( recvtv , sendtv , difftv ) ; rtt = time_to_double ( difftv ) ; printf ( " " , time_to_double ( difftv ) ) ; }
print_report: prints all the information about a successful round trip
print_report : prints all the information about a successful round trip
/* if this reply comes from source different from the previous
     one, print the full host information */ /* calculate and print the round trip time using user-level timestamps */