-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver_main.cpp
More file actions
41 lines (33 loc) · 845 Bytes
/
server_main.cpp
File metadata and controls
41 lines (33 loc) · 845 Bytes
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
#include "Index_server.h"
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <vector>
using std::cout;
using std::cerr;
using std::endl;
using std::ifstream;
using std::string;
Index_server server;
int main(int argc, char *argv[])
{
if (argc < 3) {
cerr << "Usage: indexServer <portnum> <inverted-index-filename>" << endl;
return -1;
}
int port = atoi(argv[1]);
if (port < 1024 || port > 65535) {
cerr << "Port must be between 1024 and 65535 (exclusive)." << endl;
return -1;
}
const char *fname = argv[2];
ifstream infile(fname);
if (!infile.is_open()) {
cerr << "Error opening file: " << fname << endl;
return -1;
}
cout << "Init server with fname " << fname << endl;
server.init(infile);
server.run(port);
return 0;
}