-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMEAppTollgate.h
More file actions
88 lines (62 loc) · 2 KB
/
Copy pathMEAppTollgate.h
File metadata and controls
88 lines (62 loc) · 2 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#pragma once
#include <iostream>
#include <stdio.h>
#include <string.h> //strlen
#include <stdlib.h> //strlen
#include <sys/socket.h>
#include <arpa/inet.h> //inet_addr
#include <netinet/tcp.h>
#include <unistd.h> //write
#include <pthread.h> //for threading , link with lpthread
#include <thread>
#include <map>
#include <vector>
#include <fstream>
#include <dirent.h>
#include <sstream>
#include <random>
#include <byteswap.h>
#include "SS_API.h"
using namespace std;
#define MAX_LINE 8192
#define CONNECTION_PORT 32002
#define SIMREQUEST_PORT 32003
typedef struct {
int simCount;
int simNumber;
int footer;
int threadCount;
}HANDLER_PARAM;
class CMEAppTollgate {
public:
CMEAppTollgate();
~CMEAppTollgate();
void StartServer(int simCount = 100, int simPerPod = 20);
private:
typedef thread(*callback_function)(int);
callback_function connectionFunc, simRequestFunc;
void InitEnvironment(int simCount, int simPerPod);
int SocketBinding(int _port);
int SocketAccepting(int sockfd, int port, callback_function pFunc);
int SocketConnect(const char* ip_addr, int port);
thread AcceptThread(int sockfd, int port, callback_function pFunc);
void accept_handler(int sockfd, int port, callback_function pFunc);
static thread ConnectionThread(int sockfd);
static void connection_handler(int sockfd);
static thread SimulationThread(int sockfd);
static void simulation_handler(int sockfd);
static int sendfile(FILE *fp, int sockfd);
static const char *my_itoa_buf(char *buf, size_t len, int num);
static const char *my_itoa(int num);
static pthread_mutex_t m_requestMutex;
static pthread_mutex_t m_threadMutex;
static int m_sessionCount;
static int m_tmpSessionCount;
static int m_simCount;
static int m_simPerPod;
static char **str_split(char* a_str, const char a_delim);
static int IsDouble(const char *str);
static int calcTargetTCS(int direction, int payType, int session);
static int findTCS(int type, int _start, int _end, int session);
static map<int, vector<int>> m_procInfo;
};