int main( int argc, char *argv[] ) { unsigned int ip = 0; if ( argc < 2 ) { std::cout << "Error, no IP specified." << std::endl; PrintUsage(); return EXIT_FAILURE; } ip = htonl( inet_addr( argv[1] ) ); if ( ip == INADDR_ANY || ip == INADDR_NONE ) { std::cout << "Error, invalid IP." << std::endl; PrintUsage(); return EXIT_FAILURE; } unsigned short port = DEFAULT_PORT; if ( argc >= 3 ) { if ( ( port = atoi( argv[2] ) ) == 0 ) port = DEFAULT_PORT; } std::cout << "Initializing SteamAPI..." << std::endl; // this will find and load steamclient.dll for us if ( !SteamAPI_Init() ) { std::cout << "Fatal Error: Unable to init SteamAPI." << std::endl; return EXIT_FAILURE; } std::cout << "Done!" << std::endl; CreateInterfaceFn clientFactory = Sys_GetFactory( "steamclient" ); if ( !clientFactory ) { // shouldn't ever happen, but if it does... std::cout << "Fatal Error: Unable to get steamclient factory." << std::endl; return EXIT_FAILURE; } CClient client; if ( !client.Initialize( clientFactory ) ) return EXIT_FAILURE; if ( !client.Connect( ip, port ) ) return EXIT_FAILURE; while ( client.IsRunning() ) { client.RunFrame(); Sleep( 5 ); } return EXIT_SUCCESS; }
int main() { CClient* myClient = new CClient(); myClient->Init(); myClient->Connect("127.0.0.1",60000); while(1) { //.. do stuff myClient->Update(); } myClient->Destroy(); delete myClient; return 0; }