-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
72 lines (56 loc) · 1.52 KB
/
main.cpp
File metadata and controls
72 lines (56 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <string>
#include <iostream>
#include <cstring>
#include "NodeServer.h"
#include "Client.h"
using namespace std;
int main(int argc, char* argv[]){
// Check if enough arguments are provided
if (argc < 3) {
cerr << "Usage: Server port\n";
cerr << "Client ServerIP port\n";
return 1; // Exit with error
}
cout << "Usage: Server port\n";
cout << "Client ServerIP port\n";
if (strcmp(argv[1], "Server") == 0) {
if (argc < 3) {
cerr << "Server requires a port number.\n";
return 1;
}
int serverPort = atoi(argv[2]);
if (serverPort > 0) {
NodeServer nodeServer;
nodeServer.StartServer(serverPort);
} else {
cerr << "Invalid port number.\n";
return 1;
}
}
else if (strcmp(argv[1], "Client") == 0) {
if (argc < 4) {
cerr << "Client requires ServerIP and port arguments.\n";
return 1;
}
int serverPort = atoi(argv[3]);
if (serverPort > 0) {
Client client;
client.clientConnect(argv[2], serverPort);
} else {
cerr << "Invalid port number.\n";
return 1;
}
}
else {
cerr << "Invalid argument. Usage: Server port or Client ServerIP port\n";
return 1;
}
return 0;
}
/*
int main(){
// Testing out locally
NodeManager n;
n.Write("Nebula Shift", "Project_Name", "NEW PROJECT", 1);
}
*/