StormByte C++ Library: Network module 0.0.9999
StormByte-Network is a StormByte library module for handling and create network connections
Loading...
Searching...
No Matches
protocol.hxx
1#pragma once
2
3#include <StormByte/network/visibility.h>
4
5#ifdef WINDOWS
6 #include <winsock2.h>
7#else
8 #include <netinet/in.h>
9 #include <sys/socket.h>
10#endif
11
12#include <string>
13
18namespace StormByte::Network::Connection {
23 enum class STORMBYTE_NETWORK_PUBLIC Protocol: int {
24 IPv4 = AF_INET,
25 IPv6 = AF_INET6,
26 };
27
33 constexpr STORMBYTE_NETWORK_PUBLIC std::string ProtocolString(const Protocol& protocol) noexcept {
34 switch (protocol) {
35 case Protocol::IPv4:
36 return "IPv4";
37 case Protocol::IPv6:
38 return "IPv6";
39 default:
40 return "Unknown";
41 }
42 }
43
49 constexpr STORMBYTE_NETWORK_PUBLIC int ProtocolInt(const Protocol& protocol) noexcept {
50 return static_cast<int>(protocol);
51 }
52}