Nexus Engine  v0.0.1
Loading...
Searching...
No Matches
LinuxSocket_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 {
11 bool ok = false;
12 };
13
14 struct RawAddress {
15 char host[64] = {}; // IPv4 string, null-terminated
16 unsigned short port = 0;
17 };
18
23
40
45
46 [[nodiscard]] RawError RawTranslateErrno(int err);
47
48 [[nodiscard]] RawHandle RawCreateSocket(bool isTcp);
49 void RawCloseSocket(RawHandle handle);
50
51 [[nodiscard]] bool RawSetNonBlocking(RawHandle handle, bool enabled);
52 [[nodiscard]] bool RawSetReuseAddr(RawHandle handle);
53
54 [[nodiscard]] bool RawBind(RawHandle handle, unsigned short port);
55 [[nodiscard]] bool RawListen(RawHandle handle, int backlog);
56 [[nodiscard]] RawHandle RawAccept(RawHandle handle);
57
58 [[nodiscard]] bool RawParseIPv4(const char* host, unsigned short port, RawAddress& out);
59 [[nodiscard]] RawResult RawConnect(RawHandle handle, const RawAddress& address);
60 [[nodiscard]] RawResult RawCompleteConnect(RawHandle handle);
61
62 [[nodiscard]] RawResult RawSend(RawHandle handle, const void* data, unsigned long size);
63 [[nodiscard]] RawResult RawReceive(RawHandle handle, void* buffer, unsigned long size);
64 [[nodiscard]] RawResult RawSendTo(RawHandle handle, const RawAddress& dest, const void* data, unsigned long size);
65 [[nodiscard]] RawReceiveResult RawReceiveFrom(RawHandle handle, void* buffer, unsigned long size);
66} // 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
RawError RawTranslateErrno(int err)
Definition LinuxSocket_Internal.cpp:41
RawResult RawCompleteConnect(RawHandle handle)
Definition LinuxSocket_Internal.cpp:156
RawHandle RawAccept(RawHandle handle)
Definition LinuxSocket_Internal.cpp:128
RawResult RawReceive(RawHandle handle, void *buffer, unsigned long size)
Definition LinuxSocket_Internal.cpp:202
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