-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServerNetwork.h
More file actions
executable file
·47 lines (34 loc) · 941 Bytes
/
Copy pathServerNetwork.h
File metadata and controls
executable file
·47 lines (34 loc) · 941 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
42
43
44
45
46
47
#pragma once
#ifndef SERVERNETWORK_H
#define SERVERNETWORK_H
#include "NetworkData.h"
#include <winsock2.h>
#include <Windows.h>
#include "NetworkServices.h"
#include <ws2tcpip.h>
#include <map>
using namespace std;
#pragma comment (lib, "Ws2_32.lib")
#define DEFAULT_BUFLEN 512
#define DEFAULT_PORT "6881"
class ServerNetwork
{
public:
ServerNetwork(void);
~ServerNetwork(void);
// Socket to listen for new connections
SOCKET ListenSocket;
// Socket to give to the clients
SOCKET ClientSocket;
// for error checking return values
int iResult;
// table to keep track of each client's socket
std::map<unsigned int, SOCKET> sessions;
// accept new connections
bool acceptNewClient(unsigned int & id);
// receive incoming data
int receiveData(unsigned int client_id, char * recvbuf);
// send data to all clients
void sendToAll(char * packets, int totalSize);
};
#endif