int main( int argc, char** argv ) { std::string file; bool threaded = false; if ( getopt( argc, argv, "+f:" ) == 'f' ) file = optarg; else { std::cout << "usage: " << argv[ 0 ] << " -f FILE [-t]" << std::endl; return 1; } if ( getopt( argc, argv, "+t" ) == 't' ) threaded = true; try { FIX::SessionSettings settings( file ); Application application; FIX::FileStoreFactory factory( "store" ); AcceptorPtr pAcceptor; if ( threaded ) { pAcceptor.reset( new FIX::ThreadedSocketAcceptor ( application, factory, settings ) ); } else { pAcceptor.reset( new FIX::SocketAcceptor ( application, factory, settings ) ); } pAcceptor->start(); while ( true ) FIX::process_sleep( 1 ); pAcceptor->stop(); } catch ( std::exception & e ) { std::cout << e.what(); return 2; } return 0; }
void run() { std::string myBigString; for (int i = 0; i<10000; ++i) { myBigString += as_string(i); } AC_PRINT << "the following might cause 'broken pipe' warnings - this is normal"; setSilentSuccess(true); #ifdef WIN32 int myIterations = 10; // aborting is VERY slow in windows. #else int myIterations = 100; // don't increase this or the socket table will fill up with TIME_WAIT sockets, waiting to die #endif for (int i = 0; i < myIterations; ++i) { // start server thread AcceptorPtr myAcceptor = AcceptorPtr(new ConduitAcceptor<POLICY>(_myLocalEndpoint, myLowercaseServer<POLICY>::create)); ENSURE(myAcceptor->start()); // start client { CharBuffer myInputBuffer; typename Conduit<POLICY>::Ptr myClient(new Conduit<POLICY>(_myLocalEndpoint)); ENSURE(myClient); ENSURE(myClient->sendData(myBigString.c_str(), myBigString.length())); /* string myReceiveString; while (myReceiveString.length() < myBigString.length() && myClient->isValid()) { if (myClient->receiveData(myInputBuffer)) { myReceiveString += string(&myInputBuffer[0], myInputBuffer.size()); } } ENSURE(myReceiveString == myBigString); */ } // close the server (also test if the server is cancelable) ENSURE_MSG(myAcceptor->stop(), "Cancelling server thread"); myAcceptor = AcceptorPtr(0); } setSilentSuccess(false); }
int main( int argc, char** argv ) { std::string file; if ( getopt( argc, argv, "+f:" ) == 'f' ) file = optarg; else { std::cout << "usage: " << argv[ 0 ] << " -f FILE" << std::endl; return 1; } try { FIX::SessionSettings settings( file ); Application application; FIX::FileStoreFactory factory( "store" ); AcceptorPtr pAcceptor; pAcceptor = std::auto_ptr < FIX::Acceptor > ( new FIX::SocketAcceptor ( application, factory, settings ) ); pAcceptor->start(); while ( true ) FIX::process_sleep( 1 ); pAcceptor->stop(); } catch ( std::exception & e ) { std::cout << e.what(); return 2; } return 0; }