Modbus cpp
0.1
Loading...
Searching...
No Matches
include
MB
TCP
server.hpp
1
// Modbus for c++ <https://github.com/Mazurel/Modbus>
2
// Copyright (c) 2020 Mateusz Mazur aka Mazurel
3
// Licensed under: MIT License <http://opensource.org/licenses/MIT>
4
5
#pragma once
6
7
#include <optional>
8
#include <stdexcept>
9
#include <string>
10
11
#include <libnet.h>
12
#include <netinet/in.h>
13
#include <sys/socket.h>
14
15
#include "connection.hpp"
16
17
namespace
MB::TCP {
18
class
Server
{
19
private
:
20
int
_serverfd;
21
int
_port;
22
sockaddr_in _server;
23
24
public
:
25
explicit
Server
(
int
port);
26
~Server
();
27
28
Server
(
const
Server
&) =
delete
;
29
Server
(
Server
&&moved) {
30
_serverfd = moved._serverfd;
31
_port = moved._port;
32
moved._serverfd = -1;
33
}
34
Server
&operator=(
Server
&&moved) {
35
if
(
this
== &moved)
36
return
*
this
;
37
38
_serverfd = moved._serverfd;
39
_port = moved._port;
40
moved._serverfd = -1;
41
return
*
this
;
42
}
43
44
[[nodiscard]]
int
nativeHandle() {
return
_serverfd; }
45
46
std::optional<Connection> awaitConnection();
47
};
48
}
// namespace MB::TCP
MB::TCP::Server
Definition
server.hpp:18
Generated by
1.10.0