-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.cpp
More file actions
62 lines (54 loc) · 1.86 KB
/
client.cpp
File metadata and controls
62 lines (54 loc) · 1.86 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
/********************************************************************
* Filename : client.cpp
* Author: Neetish Pathak (nepathak@paypal.com)
* Description: 1) Contains the main method for the client program
********************************************************************/
/*client.cpp*/
#include <iostream>
#include "./network/SocketClient.h"
using namespace std;
/*********************************************************************
* Function: main
* Parameters: int argc, char** argv
* Return value: int
* Description: main program for client
* argc: no. of input arguments
* argv: input arguments
* *******************************************************************/
int main(int argc, char **argv){
/*Check input parameters*/
if(argc < 4 || argc > 5){
perror("client.cpp : Incorrect usage: ./client <IP of server> <testCase> <ciphertype> OR ./client <IP of server> <testCase> <cipherType> <PortNumber>");
return 1;
}
/*Read the test Case and the cipher type*/
test_Case_Num tc = (test_Case_Num)(atoi(argv[2]));
cipher_t c = (cipher_t)(atoi(argv[3]));
/*Open the client Log file*/
clientOpFile.open(setClientLogFileName(tc,c).c_str(),std::ofstream::out);
/*Make program for extensible for multi threads*/
#if CLIENT_THREADS_ON
initializeClientConnThreads();
client.sslTcpClosure();
#endif
#if (HANDSHAKES_CNT_LOOP == TRUE)
int loopCnt = HANDSHAKES_CNT;
while(loopCnt--){
cout << "LoopCount " << HANDSHAKES_CNT-loopCnt << endl;
/*Make a client object*/
SocketClient client(argv[1], argc==5?argv[4]:PORT, tc, c);
/*Connect the client to the server*/
client.connectToServer();
/*Close TCP/SSL connection*/
client.sslTcpClosure();
/*Disconnect with the server*/
if(client.isServerConnected()){
client.disconnectFromServer();
}
}
#endif
/*close the client Log file*/
if(clientOpFile.is_open())
clientOpFile.close();
return 0;
}