4#include "SocketDescriptor.h"
6#include "../Foundation/Span.h"
7#include "../Time/Time.h"
11struct SocketNetworking;
unsigned int uint32_t
Platform independent (4) bytes unsigned int.
Definition: PrimitiveTypes.h:38
unsigned short uint16_t
Platform independent (2) bytes unsigned int.
Definition: PrimitiveTypes.h:37
An ascii string used as boolean result. SC_TRY macro forwards errors to caller.
Definition: Result.h:12
Use a SocketDescriptor as a client (example a TCP or UDP socket client).
Definition: Socket.h:66
Result read(Span< char > data, Span< char > &readData)
Read bytes from this socket blocking until they're actually received.
Result readWithTimeout(Span< char > data, Span< char > &readData, Time::Milliseconds timeout)
Read bytes from this socket blocking until they're actually received or timeout occurs.
SocketClient(const SocketDescriptor &socket)
Constructs this SocketClient from a SocketDescriptor (already created with SocketDescriptor::create)
Definition: Socket.h:69
Result connect(SocketIPAddress ipAddress)
Connect to a given address and port combination.
Result write(Span< const char > data)
Writes bytes to this socket.
Result connect(SpanStringView address, uint16_t port)
Connect to a given address and port combination.
Synchronous DNS Resolution.
Definition: Socket.h:110
static Result resolveDNS(SpanStringView host, SpanString &ipAddress)
Resolve an host string to an ip address (blocking until DNS response arrives)
Low-level OS socket handle.
Definition: SocketDescriptor.h:147
AddressFamily
Sets the address family of an IP Address (IPv4 or IPV6)
Definition: SocketDescriptor.h:73
Native representation of an IP Address.
Definition: SocketDescriptor.h:110
Networking globals initialization (Winsock2 WSAStartup)
Definition: Socket.h:123
static Result shutdownNetworking()
Shutdowns Winsock2 on Windows (WSAStartup)
static bool isNetworkingInited()
Check if initNetworking has been previously called.
static Result initNetworking()
Initializes Winsock2 on Windows (WSAStartup)
Use a SocketDescriptor as a Server (example TCP or UDP Socket Server).
Definition: Socket.h:25
Result listen(uint32_t numberOfWaitingConnections)
Start listening for incoming connections at a specific address / port combination (after bind)
SocketServer(SocketDescriptor &socket)
Build a SocketServer from a SocketDescriptor (already created with SocketDescriptor::create)
Definition: Socket.h:28
Result close()
Calls SocketDescriptor::close.
Result bind(SocketIPAddress nativeAddress)
Binds this socket to a given address / port combination.
Result accept(SocketFlags::AddressFamily addressFamily, SocketDescriptor &newClient)
Accepts a new client, blocking while waiting for it.
View over a contiguous sequence of items (pointer + size in elements).
Definition: Span.h:24
An writable view over an ASCII string (to avoid including Strings library)
Definition: Span.h:272
An read-only view over an ASCII string (to avoid including Strings library)
Definition: Span.h:249
Type-safe wrapper of uint64 used to represent milliseconds.
Definition: Time.h:29