1#if defined(HAVE_CONFIG_H)
6#pragma warning(disable : 4267)
9#include "../UdpEchoServer.hxx"
19#define RESIPROCATE_SUBSYSTEM resip::Subsystem::TEST
25 void printHelpText(
int argc,
char** argv)
override
27 cout <<
"Command line format: " << endl;
28 cout <<
" EchoServer [config_filename] [-{setting} = {value}] ...." << endl;
29 cout <<
" First argument is the configuration filename - it is optional and is never proceeded with a - or /." << endl;
30 cout <<
" Following that, config file options can be overridden." << endl;
31 cout <<
" Note: / can be used instead of - , and : can be used instead of = " << endl;
32 cout <<
"Example:" << endl;
33 cout <<
" EchoServer myconfig.config -LocalIPAddress=192.168.1.1" << endl;
37int main(
int argc,
char* argv[])
39#if defined(WIN32) && defined(_DEBUG) && defined(LEAK_CHECK)
40 resip::FindMemoryLeaks fml;
45 Data defaultConfigFilename(
"echoserver.config");
48 config.
parseConfig(argc, argv, defaultConfigFilename);
52 std::cerr <<
"Error parsing configuration: " << ex << std::endl;
61 unsigned int startingPort = config.
getConfigInt(
"StartingPort", 8000);
62 unsigned int portIncrement = config.
getConfigInt(
"PortIncrement", 2);
63 unsigned int numPorts = config.
getConfigInt(
"NumPorts", 4);
65 InfoLog(<<
"Using: LocalAddress=" << localAddress <<
", StartingPort=" << startingPort <<
", PortIncrement=" << portIncrement <<
", NumPorts=" << numPorts);
68 std::list<UdpEchoServer*> echoServers;
69 for (
unsigned int i = 0; i < numPorts; i++)
72 unsigned int port = startingPort + (portIncrement * i);
75 echoServers.push_back(echoServer);
76 InfoLog(<<
"EchoServer started " << localAddress <<
":" << port);
79 cout <<
"Press enter to exit!\n";
85 for (
auto echoServer : echoServers)
87 echoServer->shutdown();
91 for (
auto echoServer : echoServers)
100 InfoLog(<<
"EchoServer shutdown.");
102 catch (
const std::exception& e)
104 std::cerr <<
"Exception: " << e.what() <<
"\n";
int main(int argc, char *argv[])
The abstract base-class for all exceptions thrown by resip code.
virtual void parseConfig(int argc, char **argv, const resip::Data &defaultConfigFilename)
int getConfigInt(const resip::Data &name, int defaultValue) const
resip::Data getConfigData(const resip::Data &name, const resip::Data &defaultValue, bool useDefaultIfEmpty=false) const
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
static Data getLocalIpAddress(const Data &defaultInterface=Data::Empty)
Gets the IP address of "the" local interface.
static void initialize(Type type, Level level, const Data &appName, const char *logFileName=0, ExternalLogger *externalLogger=0, const Data &syslogFacility="LOG_DAEMON", MessageStructure messageStructure=Unstructured, const Data &instanceName="")
dcm! – add UnusedChecking(_enum) below;