Nexus Engine  v0.0.1
Loading...
Searching...
No Matches
WindowsScoket_Internal.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2
3#pragma once
4
6 using RawHandle = long long;
7
8 struct RawResult {
9 RawHandle value = -1;
10 int platformErrno = 0;
11 bool ok = false;
12 };
13
14 struct RawAddress {
15 char host[64] = {}; // IPv4 string, null-terminated
16 unsigned short port = 0;
17 };
18
19 struct RawReceiveResult {
20 RawResult result;
21 RawAddress sender;
22 };
23
40
41 struct RawError {
43 int platformErrno = 0;
44 };
45
46 [[nodiscard]] RawError RawTranslateLastError();
47 [[nodiscard]] RawError RawTranslateErrorCode(int platformErrno);
48
50 [[nodiscard]] RawHandle RawCreateSocket(bool isTcp);
51 void RawCloseSocket(RawHandle handle);
52
53 [[nodiscard]] bool RawSetNonBlocking(RawHandle handle, bool enabled);
54 [[nodiscard]] bool RawSetReuseAddr(RawHandle handle);
55
56 [[nodiscard]] bool RawBind(RawHandle handle, unsigned short port);
57 [[nodiscard]] bool RawListen(RawHandle handle, int backlog);
58 [[nodiscard]] RawHandle RawAccept(RawHandle handle);
59
60 [[nodiscard]] bool RawParseIPv4(const char* host, unsigned short port, RawAddress& out);
61 [[nodiscard]] RawResult RawConnect(RawHandle handle, const RawAddress& address, bool isTCPLocal);
62 [[nodiscard]] RawResult RawCompleteConnect(RawHandle handle);
63
64 [[nodiscard]] RawResult RawSend(RawHandle handle, const void* data, unsigned long size);
65 [[nodiscard]] RawResult RawReceive(RawHandle handle, void* buffer, unsigned long size);
66 [[nodiscard]] RawResult RawSendTo(RawHandle handle, const RawAddress& dest, const void* data, unsigned long size);
67 [[nodiscard]] RawReceiveResult RawReceiveFrom(RawHandle handle, void* buffer, unsigned long size);
68} // namespace Nexus::Network::Internal
Definition LinuxSocket_Internal.cpp:17
RawResult RawSendTo(RawHandle handle, const RawAddress &dest, const void *data, unsigned long size)
Definition LinuxSocket_Internal.cpp:207
bool RawListen(RawHandle handle, int backlog)
Definition LinuxSocket_Internal.cpp:124
bool RawParseIPv4(const char *host, unsigned short port, RawAddress &out)
Definition LinuxSocket_Internal.cpp:134
RawResult RawConnect(RawHandle handle, const RawAddress &address)
Definition LinuxSocket_Internal.cpp:148
bool RawSetReuseAddr(RawHandle handle)
Definition LinuxSocket_Internal.cpp:110
RawHandle RawCreateSocket(bool isTcp)
Definition LinuxSocket_Internal.cpp:90
bool RawSetNonBlocking(RawHandle handle, bool enabled)
Definition LinuxSocket_Internal.cpp:99
RawErrorKind
Definition LinuxSocket_Internal.hpp:24
@ None
Definition LinuxSocket_Internal.hpp:25
long long RawHandle
Definition LinuxSocket_Internal.hpp:6
void RawCloseSocket(RawHandle handle)
Definition LinuxSocket_Internal.cpp:95
void RawEnsureInitialized()
Definition WindowsSocket_Internal.cpp:53
RawResult RawCompleteConnect(RawHandle handle)
Definition LinuxSocket_Internal.cpp:156
RawHandle RawAccept(RawHandle handle)
Definition LinuxSocket_Internal.cpp:128
RawError RawTranslateLastError()
Definition WindowsSocket_Internal.cpp:110
RawResult RawReceive(RawHandle handle, void *buffer, unsigned long size)
Definition LinuxSocket_Internal.cpp:202
RawError RawTranslateErrorCode(int platformErrno)
Definition WindowsSocket_Internal.cpp:61
RawReceiveResult RawReceiveFrom(RawHandle handle, void *buffer, unsigned long size)
Definition LinuxSocket_Internal.cpp:216
RawResult RawSend(RawHandle handle, const void *data, unsigned long size)
Definition LinuxSocket_Internal.cpp:197
bool RawBind(RawHandle handle, unsigned short port)
Definition LinuxSocket_Internal.cpp:115
@ MessageTooLarge
Definition NetworkError.cppm:25
@ NotConnected
Definition NetworkError.cppm:20
@ PermissionDenied
Definition NetworkError.cppm:27
@ None
Definition NetworkError.cppm:13
@ NetworkUnreachable
Definition NetworkError.cppm:23
@ Unknown
Definition NetworkError.cppm:29
@ HostUnreachable
Definition NetworkError.cppm:22
@ ConnectionRefused
Definition NetworkError.cppm:19
@ ConnectionReset
Definition NetworkError.cppm:17
@ Timeout
Definition NetworkError.cppm:24
@ WouldBlock
Definition NetworkError.cppm:14
@ ConnectionAborted
Definition NetworkError.cppm:18
@ ConnectionInProgress
Definition NetworkError.cppm:15
@ AddressInUse
Definition NetworkError.cppm:21
Definition LinuxSocket_Internal.hpp:14
char host[64]
Definition LinuxSocket_Internal.hpp:15
unsigned short port
Definition LinuxSocket_Internal.hpp:16
Definition LinuxSocket_Internal.hpp:41
RawErrorKind kind
Definition LinuxSocket_Internal.hpp:42
int platformErrno
Definition LinuxSocket_Internal.hpp:43
Definition LinuxSocket_Internal.hpp:19
RawAddress sender
Definition LinuxSocket_Internal.hpp:21
RawResult result
Definition LinuxSocket_Internal.hpp:20
Definition LinuxSocket_Internal.hpp:8
RawHandle value
Definition LinuxSocket_Internal.hpp:9
int platformErrno
Definition LinuxSocket_Internal.hpp:10
bool ok
Definition LinuxSocket_Internal.hpp:11