-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cc
25 lines (20 loc) · 928 Bytes
/
main.cc
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
#include <iostream>
#include <thread>
#include "server.h"
#include "structs.h"
#include "timestamp.h"
void printRequest(struct udp_request* request) {
printf("%s [INFO] packet is %ld bytes long\n", currentDateTime().c_str(), request->bytesReceived);
std::flush(std::cout);
}
void beforeRequest(char* /* data */, char* /* errorCategory */, int /*errorCode*/, long bytesTransferred, char* host, int port) {
printf("%s [INFO] before request executed\n", currentDateTime().c_str());
printf("%s [INFO] a new packet from %s:%d received\n", currentDateTime().c_str(), host, port);
std::flush(std::cout);
}
void afterRequest(char* /* data */, long /* bytesTransferred */, char* /* host */, int /* port */) {
printf("%s [INFO] after request\n", currentDateTime().c_str());
}
int main() {
startBoostServer(&printRequest, &beforeRequest, &afterRequest, 20777, 2048, std::thread::hardware_concurrency());
}