8#include <cosmos/fs/FDFile.hxx>
9#include <cosmos/net/SocketOptions.hxx>
10#include <cosmos/net/types.hxx>
11#include <cosmos/utils.hxx>
16class SendMessageHeader;
17class ReceiveMessageHeader;
46 READ_WRITE = SHUT_RDWR
58 auto sockOptions()
const {
63 void getSockName(SocketAddress &addr);
74 void shutdown(
const Direction dir);
80 const SocketFamily family,
81 const SocketType type,
82 const SocketFlags flags = SocketFlags{SocketFlag::CLOEXEC},
127 void listen(
const size_t backlog);
154 return send(data.data(), data.size(), flags);
167 size_t sendTo(
const void *buf,
size_t length,
const SocketAddress &addr,
168 const MessageFlags flags = MessageFlags{});
173 return sendTo(data.data(), data.size(), addr, flags);
197 void sendMessage(SendMessageHeader &header,
const SocketAddress* addr =
nullptr);
204 size_t receive(
void *buf,
size_t length,
const MessageFlags flags = MessageFlags{});
217 std::pair<size_t, AddressFilledIn> receiveFrom(
218 void *buf,
size_t length, SocketAddress &addr,
219 const MessageFlags flags = MessageFlags{});
244 AddressFilledIn receiveMessage(ReceiveMessageHeader &header, SocketAddress *addr =
nullptr);
File objects that are opened from existing FileDescriptor objects.
Thin Wrapper around OS file descriptors.
Strong template type to wrap boolean values in a named type.
Base class for all types of socket addresses.
Generic socket level option setter/getter helper.
Base class for Socket types with ownership of a FileDescriptor.
Direction
Type used in Socket::shutdown().
Socket(FileDescriptor fd, const AutoCloseFD auto_close)
Creates a new socket from the given existing file descriptor.
size_t sendTo(const std::string_view data, const SocketAddress &addr, const MessageFlags flags=MessageFlags{})
Variant of sendTo() that takes a std::string_view container instead of a raw input buffer.
size_t send(const std::string_view data, const MessageFlags flags=MessageFlags{})
Variant of send() that takes a std::string_view container instead of a raw input buffer.
SocketProtocol
Specific protocol to use on a socket.