int main(int argc, char** argv) { /*open_progress(); set_progress(10, "abc\ndef\nghi"); std::this_thread::sleep_for(std::chrono::milliseconds(250)); set_progress(20, "xyz\n123\n456"); std::this_thread::sleep_for(std::chrono::milliseconds(250)); close_progress(); return 0;*/ if(argc < 5) { std::cerr << "Usage: " << argv[0] << " <server> <port> <login> <password>" << std::endl; return -1; } if(!open_progress()) { log_err("Cannot open progress dialog."); return -1; } TcpClient client; client.add_receiver(received); client.add_disconnect(disconnected); client.add_connect(connected); if(!client.connect(argv[1], argv[2])) { log_err("Error: Cannot connect."); return -1; } std::string strLogin = argv[3]; std::string strPwd = argv[4]; client.write(strLogin + " " + strPwd + "\n"); std::this_thread::sleep_for(std::chrono::milliseconds(250)); while(1) { client.write("counter getcounts\ncounter getmonitor 1\ncounter getpreset\n"); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); } close_progress(); return 0; }
int main(int argc, char** argv) { if(argc < 3) { std::cerr << "Usage: " << argv[0] << " <server> <port>" << std::endl; return -1; } TcpClient client; //TstOut tstout; //client.add_receiver(boost::bind(&TstOut::print, &tstout, _1)); client.add_receiver(received); client.add_disconnect(disconnected); client.add_connect(connected); if(!client.connect(argv[1], argv[2])) { log_err("Cannot connect."); return -1; } std::string strMsg; while(client.is_connected()) { std::getline(std::cin, strMsg); if(strMsg == "!exit!") break; strMsg+="\n"; client.write(strMsg); } return 0; }