AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
AUdpSocket.h
1/*
2 * AUI Framework - Declarative UI toolkit for modern C++20
3 * Copyright (C) 2020-2024 Alex2772 and Contributors
4 *
5 * SPDX-License-Identifier: MPL-2.0
6 *
7 * This Source Code Form is subject to the terms of the Mozilla Public
8 * License, v. 2.0. If a copy of the MPL was not distributed with this
9 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 */
11
12#pragma once
13
14#include <cstdint>
15#include <AUI/Common/AString.h>
16#include <AUI/Network.h>
17
18
19#include "AAbstractSocket.h"
20#include "AUI/IO/IInputStream.h"
21#include "AUI/IO/AIOException.h"
22#include "AUI/IO/IOutputStream.h"
23
24#include "AInet4Address.h"
25#include "AUI/Common/AByteBufferView.h"
26
27class AByteBuffer;
28
33class API_AUI_NETWORK AUdpSocket : public AAbstractSocket
34{
35public:
36
41 AUdpSocket(uint16_t port);
42
43
47 AUdpSocket();
48
49 AUdpSocket(const AUdpSocket&) = delete;
50 ~AUdpSocket() override = default;
51
52
58 void write(AByteBufferView buf, const AInet4Address& dst);
59
65 void read(AByteBuffer& buf, AInet4Address& dst);
66
67protected:
68 int createSocket() override;
69
70private:
71 AInet4Address mSelf;
72
73};
virtual int createSocket()=0
Creates socket handle.
Acts like std::string_view but for AByteBuffer.
Definition AByteBufferView.h:24
std::vector-like growing array for byte storage.
Definition AByteBuffer.h:31
Represents an ipv4 address with port.
Definition AInet4Address.h:25
AUdpSocket(uint16_t port)
Creates socket.
Definition AUdpSocket.cpp:29
void read(AByteBuffer &buf, AInet4Address &dst)
Read data.
Definition AUdpSocket.cpp:55
void write(AByteBufferView buf, const AInet4Address &dst)
Sends data by address.
Definition AUdpSocket.cpp:44