static int BeginNetwork( void ) { if( !NetworkStart() ) return 0; return 1; }
// command line option // time // output file... SaneWinMain( argc, argv ) { NetworkStart(); pcListen = ServeUDP( WIDE("0.0.0.0"), 514, LogRead, NULL ); while( pcListen ) WakeableSleep( SLEEP_FOREVER ); printf( WIDE("Failed to start.") ); return 1; }
int main( int argc, char** argv ) { SOCKADDR *sa; int n; if( argc < 2 ) { printf( "usage: %s <Telnet IP[:port]>\n", argv[0] ); return 0; } SystemLog( "Starting the network" ); NetworkStart(); SystemLog( "Started the network" ); sa = CreateSockAddress( argv[1], 23 ); //if( argc >= 3 ) port = atoi( argv[2] ); else port = 23; pc_user = OpenTCPClientAddrExx( sa, ReadComplete, Closed, NULL, Connected ); if( !pc_user ) { SystemLog( "Failed to open some port as telnet" ); printf( "failed to open %s%s\n", argv[1], strchr(argv[1],':')?"":":telnet[23]" ); return 0; } for( n = 0; n < 1000; n++ ) { if( (rand() & 3) != 0 ) { WakeableSleep( rand() %1000 ); } lprintf( "..." ); RemoveClient( pc_user ); pc_user = OpenTCPClientAddrExx( sa, ReadComplete, Closed, NULL, Connected ); lprintf( "..." ); if( (rand() &3) < 3 ) { fflush( stdout ); while( !connected ) Relinquish(); } if( connected ) { lprintf( "send." ); SendTCP( pc_user, "test", 4 ); } } return -1; }
int main( int argc, char **argv ) { NetworkStart(); if( argc < 2 ) { printf( WIDE("Usage: %s [scUu]\n"), argv[0] ); printf( WIDE(" s - server\n") ); printf( WIDE(" c - client\n") ); printf( WIDE(" U - use a unix socket instead of tcp\n") ); printf( WIDE(" u - use a UDP socket instead of tcp\n") ); printf( WIDE(" s and c may be specified together to test single-process\n") ); return 0; } while( argc > 1 ) { char *p = argv[1]; while( p[0] ) { switch( p[0] ) { case 's': case 'S': l.flags.bServer = 1; break; case 'c': case 'C': l.flags.bClient = 1; break; case 'U': l.flags.bUnix = 1; l.flags.bUDP = 0; break; case 'u': l.flags.bUDP = 1; l.flags.bUnix = 0; break; } p++; } argv++; argc--; } if( l.flags.bServer ) { OpenServer(); } if( l.flags.bClient ) { OpenClient(); } if( l.flags.bClient ) { // all tests are client based. if( l.flags.bUDP ) { UDPTest1Byte(); } else TCPTest1Byte(); // all tests are client based. if( l.flags.bUDP ) { UDPTest1000Byte(); } else TCPTest1000Byte(); } else WakeableSleep( 10000 ); return 0; }
int main( int argc, char* argv[] ) { return NetworkStart( argc, argv, networkAppMain ); }