-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServer.cpp
More file actions
27 lines (22 loc) · 697 Bytes
/
Server.cpp
File metadata and controls
27 lines (22 loc) · 697 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
#include "Server.hpp"
using std::cerr;
using std::cin;
using std::cout;
using std::endl;
using std::string;
ip::udp::endpoint Server::SERVER_ENDPOINT(
boost::asio::ip::address::from_string("127.0.0.1"), 5000);
void Server::serve() {
serverSocket.async_receive(
boost::asio::buffer(rcv_data, 1024),
[&](std::error_code ec, size_t bytes_received) {
if (!ec && bytes_received > 0) {
cout << "RCV: " << std::string_view(rcv_data, bytes_received)
<< endl;
} else {
cout << "ERROR, BYTES: " << bytes_received << ec.message()
<< endl;
}
});
ctx.run();
}