StormByte C++ Library: Network module 1.1.0
StormByte-Network is the C++26 networking module of the StormByte suite.
Loading...
Searching...
No Matches
protocol.hxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024-2026 David C. Manuelda (StormBytePP)
3 *
4 * This file is part of StormByte-Network.
5 *
6 * StormByte-Network is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License version 3
8 * or later, as published by the Free Software Foundation.
9 *
10 * StormByte-Network is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with StormByte-Network. If not, see
17 * <https://www.gnu.org/licenses/lgpl-3.0.html>.
18 */
19
20#pragma once
21
23
24#ifdef WINDOWS
25 #include <winsock2.h>
26#else
27 #include <netinet/in.h>
28 #include <sys/socket.h>
29#endif
30
31#include <string>
32
42 IPv4 = AF_INET,
43 IPv6 = AF_INET6,
44 };
45
51 constexpr STORMBYTE_NETWORK_PUBLIC std::string ProtocolString(const Protocol& protocol) noexcept {
52 switch (protocol) {
53 case Protocol::IPv4: return "IPv4";
54 case Protocol::IPv6: return "IPv6";
55 default: return "Unknown";
56 }
57 }
58
64 constexpr STORMBYTE_NETWORK_PUBLIC int ProtocolInt(const Protocol& protocol) noexcept {
65 return static_cast<int>(protocol);
66 }
67}
Connection types of the Network module.
Definition client.hxx:31
Protocol
Address family for sockets.
Definition protocol.hxx:41
constexpr int ProtocolInt(const Protocol &protocol) noexcept
Protocol as AF_* integer.
Definition protocol.hxx:64
constexpr std::string ProtocolString(const Protocol &protocol) noexcept
Protocol as text.
Definition protocol.hxx:51
#define STORMBYTE_NETWORK_PUBLIC
Definition visibility.h:28