-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.cpp
More file actions
42 lines (35 loc) · 1.31 KB
/
server.cpp
File metadata and controls
42 lines (35 loc) · 1.31 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
/********************************************************************
* Filename : SocketClient.cpp
* Author: Neetish Pathak (nepathak@paypal.com)
* Description: 1) contains main function for server program.
********************************************************************/
/*server.cpp*/
#include "network/SocketServer.h"
using namespace std;
/*********************************************************************
* Function: main
* Parameters: int argc, char** argv
* Return type: int
* Description: main program for server
* argc: no. of input arguments
* argv: input arguments
* *******************************************************************/
int main(int argc, char **argv){
/*Check the input parameters*/
if(argc < 3 || argc > 4){
perror("server.cpp : Incorrect usage: ./server <testCase> <ciphertype> OR ./client <testCase> <cipherType> <PortNumber>");
return 1;
}
/*Read the testcase and cipher type*/
test_Case_Num tc = (test_Case_Num)(atoi(argv[1]));
cipher_t c = (cipher_t)(atoi(argv[2]));
/*Open serverLog file*/
serverOpFile.open(setServerLogFileName(tc,c).c_str(),std::ofstream::out);
/*Initialize the server program*/
SocketServer server(argc==4?argv[3]:PORT,tc,c);
server.listen();
/*Close the server log file*/
if(serverOpFile.is_open())
serverOpFile.close();
return 0;
}