summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/main.cpp b/src/main.cpp
index df50598..13ed842 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -33,7 +33,6 @@ static void help() {
log(ERR, "usage: chat-server <port>");
}
-// TODO: ARGC, ARGV. the CServer ctor should take a port number
int main(int argc, char *argv[]) try {
std::vector<std::string> args{argv + 1, argv + argc};
if (args.empty()) {
@@ -48,17 +47,16 @@ int main(int argc, char *argv[]) try {
return EXIT_SUCCESS;
} else if (std::ranges::all_of(arg, ::isdigit)) {
port = std::stoi(arg);
- if (std::stoi(arg) < 0) {
+ if (port < 0) {
log(ERR, "Port number must be greater than 0");
return EXIT_FAILURE;
- } else if (std::stoi(arg) > 65535) {
+ } else if (port > 65535) {
log(ERR, "Port number must be less than 65536");
return EXIT_FAILURE;
}
- port = std::stoi(arg);
log(LOG, "Port number: {}", port);
}
}