#include "common.h"

// ретранслятор c fork
int main( int argc, char *argv[] ) {
   int ls = getsocket( FORK_PORT ), rs;   
   setv( argc, argv );
   while( true ) {
      if( ( rs = accept( ls, NULL, NULL ) ) < 0 ) errx( "accept error" );
      pid_t pid = fork();
      if( pid < 0 ) errx( "fork error" );
      if( pid == 0 ) {
         close( ls );
         retrans( rs );
         close( rs );
         if( debug ) cout << "*" << flush;                  
         exit( EXIT_SUCCESS );
      }
      else close( rs );
   };
   exit( EXIT_SUCCESS );
};

