/******************************************************************* * receiveclient.cpp * * * * Copyright (C) 2004, Inv3rsion, LLC, * * Goffstown, NH * * * * Author(s): Scott Coppen, Todd Furlong * *******************************************************************/ #include #include // Program Info: Example SinterPoint receive client // Connects to a SinterPoint server and prints out text strings as they // are received int main( int argc, char** argv ) { sinter::Receiver receiver; // Our SinterPoint receiver class int rc; if(argc != 2) { std::cout << "Usage: ./receiveclient servername" << std::endl; return ( 0 ); } // Declare program name & version info to server receiver.SetType("DEMO"); // Session Name receiver.SetVersion("1.0"); // version of this client // Configure server. This only takes effect if no other clients are // connected with a matching session name. If the server already has // another client connected, this client must obey the server configuration // set up by that earlier client. receiver.SetMaxSend(1); // restrict server to only allow one send client if(!receiver.Connect( argv[1] )) { std::cout << "Receiving..." << std::endl; while( 1 ) // receive & print until Ctrl-C { if(rc = receiver.Receive( -1 )) // -1 means wait forever { fwrite( (void *) receiver.Data(), 1, rc, stdout ); } } } else std::cout << "Error connecting to " << argv[1] << std::endl; return( 0 ); }