forked from mckeemseattleu/CPSC5042CSServer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRPCServer.h
More file actions
54 lines (45 loc) · 1.44 KB
/
RPCServer.h
File metadata and controls
54 lines (45 loc) · 1.44 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
/* RPCServer.cpp : This file contains the 'main' function.Program execution begins and ends there.
This is a very very simple example of a CPSC5042 Server that will listen to
a CPSC5042 Client
Version 1 will have the server handle one client at a time. The server will:
- Wait for connection from client
- Process the Connect API once connect
- Process all RPC requests until the client does a Disconnect RPC
- This intial server will handle 3 RPC's:
- Connect
- HowManyChars (will return HowManyChars are in the input message)
- Disconnnect
server, then run the various RPC's that might happen between the server and
client
*/
#pragma once
#include <unistd.h>
#include <stdio.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <string.h>
#include <vector>
#include <iterator>
class RPCServer
{
public:
RPCServer(const char *serverIP, int port);
~RPCServer();
bool StartServer();
bool ListenForClient();
bool ProcessRPC();
void ParseTokens(char* buffer, std::vector<std::string>& a);
private:
int m_rpcCount;
int m_server_fd;
int m_socket;
char* m_serverIP;
int m_port;
struct sockaddr_in m_address;
// First one in this function should be a connect, and it
// will continue try to process RPC's until a Disconnect happens
bool ProcessConnectRPC(std::vector<std::string>& arrayTokens);
bool ProcessStatusRPC();
bool ProcessDisconnectRPC();
};