StormByte C++ Library: Network module
1.1.0
StormByte-Network is the C++26 networking module of the StormByte suite.
Loading...
Searching...
No Matches
lib
public
StormByte
network
connection
rw.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
22
#include <
StormByte/network/visibility.h
>
23
24
#include <string>
25
29
namespace
StormByte::Network::Connection
{
33
namespace
Read {
38
enum class
STORMBYTE_NETWORK_PUBLIC
Result
{
39
Success
,
40
WouldBlock
,
41
Closed
,
42
Failed
,
43
Timeout
,
44
ShutdownRequest
45
};
46
}
47
51
namespace
Write {
56
enum class
STORMBYTE_NETWORK_PUBLIC
Result
{
57
Success
,
58
Failed
59
};
60
}
61
67
constexpr
STORMBYTE_NETWORK_PUBLIC
std::string
ToString
(
const
StormByte::Network::Connection::Read::Result
& result)
noexcept
{
68
switch
(result) {
69
case
StormByte::Network::Connection::Read::Result::Success
:
return
"Success"
;
70
case
StormByte::Network::Connection::Read::Result::WouldBlock
:
return
"WouldBlock"
;
71
case
StormByte::Network::Connection::Read::Result::Failed
:
return
"Failed"
;
72
case
StormByte::Network::Connection::Read::Result::Closed
:
return
"Closed"
;
73
case
StormByte::Network::Connection::Read::Result::Timeout
:
return
"Timeout"
;
74
case
StormByte::Network::Connection::Read::Result::ShutdownRequest
:
return
"ShutdownRequest"
;
75
default
:
return
"Unknown"
;
76
}
77
}
78
84
constexpr
STORMBYTE_NETWORK_PUBLIC
std::string
ToString
(
const
StormByte::Network::Connection::Write::Result
& result)
noexcept
{
85
switch
(result) {
86
case
StormByte::Network::Connection::Write::Result::Success
:
return
"Success"
;
87
case
StormByte::Network::Connection::Write::Result::Failed
:
return
"Failed"
;
88
default
:
return
"Unknown"
;
89
}
90
}
91
}
StormByte::Network::Connection::Read::Result
Result
Outcome of a wait/read.
Definition
rw.hxx:38
StormByte::Network::Connection::Read::Result::Closed
@ Closed
Local/socket closed.
StormByte::Network::Connection::Read::Result::Success
@ Success
Data available or read ok.
StormByte::Network::Connection::Read::Result::ShutdownRequest
@ ShutdownRequest
Peer shutdown detected.
StormByte::Network::Connection::Read::Result::Timeout
@ Timeout
Wait timed out.
StormByte::Network::Connection::Read::Result::Failed
@ Failed
Hard failure.
StormByte::Network::Connection::Read::Result::WouldBlock
@ WouldBlock
Non-blocking: no data yet.
StormByte::Network::Connection::Write::Result
Result
Outcome of a write.
Definition
rw.hxx:56
StormByte::Network::Connection::Write::Result::Success
@ Success
Write completed.
StormByte::Network::Connection::Write::Result::Failed
@ Failed
Write failed.
StormByte::Network::Connection
Connection types of the Network module.
Definition
client.hxx:31
StormByte::Network::Connection::ToString
constexpr std::string ToString(const StormByte::Network::Connection::Read::Result &result) noexcept
Read result as text.
Definition
rw.hxx:67
visibility.h
STORMBYTE_NETWORK_PUBLIC
#define STORMBYTE_NETWORK_PUBLIC
Definition
visibility.h:28
Generated by
1.9.8