Choose hostname and port (for server and client part)
This commit is contained in:
@@ -1,9 +1,34 @@
|
||||
#include "server.hpp"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
Server server;
|
||||
server.start();
|
||||
int opt;
|
||||
std::string host = "localhost";
|
||||
short unsigned port = 1024u;
|
||||
|
||||
while ((opt = getopt(argc, argv, "h:p:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'h':
|
||||
host = optarg;
|
||||
break;
|
||||
case 'p':
|
||||
port = static_cast<unsigned short>(atoi(optarg));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Server server;
|
||||
server.start(host, port);
|
||||
} catch (const std::runtime_error& e){
|
||||
std::cerr << "Client application error: " << e.what() << std::endl;
|
||||
return 1;
|
||||
} catch (...){
|
||||
std::cerr << "Unexpected error in client application" << std::endl;
|
||||
return 2;
|
||||
}
|
||||
|
||||
std::cout << "Server application finished" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user