9#include "socket_event_intf.hpp"
10#include "../utility/utility.hpp"
11#include "../macros.hpp"
14hi_export_module(hikogui.dispatch.socket_event : impl);
16hi_export
namespace hi::inline
v1 {
18[[nodiscard]]
constexpr socket_event socket_event_from_win32(
long rhs)
noexcept
20 auto r = socket_event::none;
22 r |= (rhs & FD_READ) ? socket_event::read : socket_event::none;
23 r |= (rhs & FD_WRITE) ? socket_event::write : socket_event::none;
24 r |= (rhs & FD_CLOSE) ? socket_event::close : socket_event::none;
25 r |= (rhs & FD_CONNECT) ? socket_event::connect : socket_event::none;
26 r |= (rhs & FD_ACCEPT) ? socket_event::accept : socket_event::none;
27 r |= (rhs & FD_OOB) ? socket_event::out_of_band : socket_event::none;
28 r |= (rhs & FD_QOS) ? socket_event::qos : socket_event::none;
29 r |= (rhs & FD_GROUP_QOS) ? socket_event::group_qos : socket_event::none;
30 r |= (rhs & FD_ADDRESS_LIST_CHANGE) ? socket_event::address_list_change : socket_event::none;
31 r |= (rhs & FD_ROUTING_INTERFACE_CHANGE) ? socket_event::routing_interface_changed : socket_event::none;
36[[nodiscard]]
constexpr socket_error socket_error_from_win32(
int rhs)
noexcept
39 case 0:
return socket_error::success;
40 case WSAEAFNOSUPPORT:
return socket_error::af_not_supported;
41 case WSAECONNREFUSED:
return socket_error::connection_refused;
42 case WSAENETUNREACH:
return socket_error::network_unreachable;
43 case WSAENOBUFS:
return socket_error::no_buffers;
44 case WSAETIMEDOUT:
return socket_error::timeout;
45 case WSAENETDOWN:
return socket_error::network_down;
46 case WSAECONNRESET:
return socket_error::connection_reset;
47 case WSAECONNABORTED:
return socket_error::connection_aborted;
48 default: hi_no_default();
52[[nodiscard]]
constexpr socket_events socket_events_from_win32(WSANETWORKEVENTS
const& rhs)
noexcept
54 auto r = socket_events{};
55 r.events = socket_event_from_win32(rhs.lNetworkEvents);
56 r.errors[
bit(socket_event::read)] = socket_error_from_win32(rhs.iErrorCode[FD_READ_BIT]);
57 r.errors[
bit(socket_event::write)] = socket_error_from_win32(rhs.iErrorCode[FD_WRITE_BIT]);
58 r.errors[
bit(socket_event::close)] = socket_error_from_win32(rhs.iErrorCode[FD_CLOSE_BIT]);
59 r.errors[
bit(socket_event::connect)] = socket_error_from_win32(rhs.iErrorCode[FD_CONNECT_BIT]);
60 r.errors[
bit(socket_event::accept)] = socket_error_from_win32(rhs.iErrorCode[FD_ACCEPT_BIT]);
61 r.errors[
bit(socket_event::out_of_band)] = socket_error_from_win32(rhs.iErrorCode[FD_OOB_BIT]);
62 r.errors[
bit(socket_event::qos)] = socket_error_from_win32(rhs.iErrorCode[FD_QOS_BIT]);
63 r.errors[
bit(socket_event::group_qos)] = socket_error_from_win32(rhs.iErrorCode[FD_GROUP_QOS_BIT]);
64 r.errors[
bit(socket_event::address_list_change)] = socket_error_from_win32(rhs.iErrorCode[FD_ADDRESS_LIST_CHANGE_BIT]);
65 r.errors[
bit(socket_event::routing_interface_changed)] =
66 socket_error_from_win32(rhs.iErrorCode[FD_ROUTING_INTERFACE_CHANGE_BIT]);
Rules for working with win32 headers.
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
constexpr size_t bit(socket_event const &rhs) noexcept
Get the bit index of the single bit of the socket_event mask.
Definition socket_event_intf.hpp:54