#include "common.h"

// последовательный ретранслятор тестовых пакетов TCP
int main( int argc, char *argv[] ) {
   int ls, rs, i = 0, cl = calibr( 10000 );
   cout << "wait ..." << flush;
   uint64_t cps = proc_hz(); // cycles per sec.
   cout << '\r';
   ls = getsocket( SINGLE_PORT );
   setv( argc, argv );
   while( true ) {
      if( ( rs = accept( ls, NULL, NULL ) ) < 0 ) errx( "accept error" );
      uint64_t cycle = rdtsc();
      retrans( rs );
      cycle = rdtsc() - cycle;
      cycle -= cl;
      close( rs );
      cout << cycle << "[" << cycle * 1000000 / cps << "]";   // sec. / 10E6
      if( i++ % 5 == 4 ) cout << endl; else cout << '\t'; cout << flush;
   };
   exit( EXIT_SUCCESS );
};

