EasySockets v2.2.1
A simple, cross platform socket library for C++.
Loading...
Searching...
No Matches
SocketApi.hpp
1#pragma once
2
3#include "Addresses.hpp"
4#include "SocketTypes.hpp"
5
6namespace es
7{
8 template<typename T>
9 concept SocketApi = requires(T t, EndPoint end_point, char* buffer, int len, IpVersion ip_version)
10 {
11 { t.bind_to(end_point) };
12 { t.connect_to(end_point) };
13 { t.listen_for_connections(len) };
14 { t.accept_connection() } -> std::same_as<T>;
15 { t.receive_data(buffer, len) } -> std::same_as<int64_t>;
16 { t.receive_data_from(buffer, len, end_point) } -> std::same_as<int64_t>;
17 { t.send_data(buffer, len) } -> std::same_as<int64_t>;
18 { t.send_data_to(buffer, len, end_point) } -> std::same_as<int64_t>;
19 { t.close() };
20 { T::make_connected_tcp(end_point) } -> std::same_as<T>;
21 { T::make_connected_udp(end_point) } -> std::same_as<T>;
22 { T::make_bound_tcp(end_point.port, ip_version) } -> std::same_as<T>;
23 { T::make_bound_tcp(end_point.port) } -> std::same_as<T>;
24 { T::make_bound_udp(end_point.port, ip_version) } -> std::same_as<T>;
25 { T::make_bound_udp(end_point.port) } -> std::same_as<T>;
26 }
27 && std::constructible_from<T, IpVersion, Protocol>
28 && !std::copyable<T>
29 && std::movable<T>;
30}
Definition SocketApi.hpp:9
IpVersion
Version of IP address.
Definition SocketTypes.hpp:11
Definition Addresses.hpp:7
Represents the address + port that identifies a connection. Initialized by {Address,...
Definition Addresses.hpp:29