2023-12-17 03:29:08 -08:00
|
|
|
#pragma once
|
|
|
|
|
2024-01-14 09:38:57 -08:00
|
|
|
#include "ehs/EHS.h"
|
|
|
|
#include "ehs/Str.h"
|
2023-12-17 03:29:08 -08:00
|
|
|
#include "Socket.h"
|
|
|
|
|
2023-12-17 15:56:13 -08:00
|
|
|
namespace ehs
|
2023-12-17 03:29:08 -08:00
|
|
|
{
|
|
|
|
class BaseUDP
|
|
|
|
{
|
|
|
|
protected:
|
2023-12-18 21:04:53 -08:00
|
|
|
AddrType type;
|
2023-12-17 03:29:08 -08:00
|
|
|
Str_8 address;
|
|
|
|
UInt_16 port;
|
|
|
|
bool bound;
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~BaseUDP() = default;
|
|
|
|
|
|
|
|
BaseUDP();
|
|
|
|
|
2023-12-18 21:04:53 -08:00
|
|
|
BaseUDP(AddrType type);
|
2023-12-17 03:29:08 -08:00
|
|
|
|
|
|
|
BaseUDP(BaseUDP&& udp) noexcept;
|
|
|
|
|
|
|
|
BaseUDP(const BaseUDP& udp);
|
|
|
|
|
|
|
|
BaseUDP& operator=(BaseUDP&& udp) noexcept;
|
|
|
|
|
|
|
|
BaseUDP& operator=(const BaseUDP& udp);
|
|
|
|
|
|
|
|
virtual void Release() = 0;
|
|
|
|
|
2023-12-18 21:04:53 -08:00
|
|
|
virtual void Bind(AddrType type, const Str_8& address, UInt_16 port) = 0;
|
2023-12-17 03:29:08 -08:00
|
|
|
|
2023-12-18 21:04:53 -08:00
|
|
|
virtual UInt_64 Send(AddrType type, const Str_8& address, UInt_16 port, const Byte* data, UInt_64 size) = 0;
|
2023-12-17 03:29:08 -08:00
|
|
|
|
2023-12-18 21:04:53 -08:00
|
|
|
virtual UInt_64 Receive(AddrType* type, Str_8* address, UInt_16* port, Byte* data, UInt_64 size) = 0;
|
2023-12-17 03:29:08 -08:00
|
|
|
|
|
|
|
bool IsBound() const;
|
|
|
|
|
2023-12-18 21:04:53 -08:00
|
|
|
virtual void SetBlocking(bool blocking) = 0;
|
2023-12-17 03:29:08 -08:00
|
|
|
|
|
|
|
virtual bool IsBlocking() const = 0;
|
|
|
|
|
2023-12-18 21:04:53 -08:00
|
|
|
AddrType GetLocalAddressType() const;
|
2023-12-17 03:29:08 -08:00
|
|
|
|
|
|
|
Str_8 GetLocalAddress() const;
|
|
|
|
|
|
|
|
UInt_16 GetLocalPort() const;
|
|
|
|
|
|
|
|
virtual bool IsValid() const = 0;
|
|
|
|
};
|
|
|
|
}
|