|
SDL3pp
A slim C++ wrapper for SDL3
|
An object that represents a datagram connection to another system. More...
Public Member Functions | |
| constexpr | DatagramSocket (DatagramSocketRaw resource) noexcept |
| Constructs from raw DatagramSocket. | |
| constexpr | DatagramSocket (DatagramSocket &&other) noexcept |
| Move constructor. | |
| DatagramSocket (AddressRef addr, Uint16 port, PropertiesRef props) | |
| Create and bind a new datagram socket. | |
| ~DatagramSocket () | |
| Destructor. | |
| constexpr DatagramSocket & | operator= (DatagramSocket &&other) noexcept |
| Assignment operator. | |
| Public Member Functions inherited from SDL::DatagramSocketBase | |
| void | Destroy () |
| Dispose of a previously-created datagram socket. | |
| bool | SendDatagram (AddressRef address, Uint16 port, const void *buf, int buflen) |
| Send a new packet over a datagram socket to a remote system. | |
| bool | ReceiveDatagram (Datagram &dgram) |
| Receive a new packet that a remote system sent to a datagram socket. | |
| Datagram | ReceiveDatagram () |
| Receive a new packet that a remote system sent to a datagram socket. | |
| void | SimulateDatagramPacketLoss (int percent_loss) |
| Enable simulated datagram socket failures. | |
| constexpr | ResourceBaseT ()=default |
| Default constructor, creates null/invalid resource. | |
| constexpr | ResourceBaseT (RawPointer resource) |
| Constructs from resource pointer. | |
| constexpr | ResourceBaseT (std::nullptr_t) |
| Constructs null/invalid. | |
| constexpr | ResourceBaseT (const ResourceBaseT &)=default |
| Copy constructor. | |
| constexpr | ResourceBaseT (ResourceBaseT &&) noexcept=default |
| Move constructor. | |
| Public Member Functions inherited from SDL::ResourceBaseT< DatagramSocketRaw > | |
| constexpr | ResourceBaseT ()=default |
| Default constructor, creates null/invalid resource. | |
| constexpr | operator bool () const |
| Converts to bool. | |
| constexpr auto | operator<=> (const ResourceBaseT &other) const=default |
| Comparison. | |
| constexpr RawConstPointer | operator-> () const noexcept |
| member access to underlying resource pointer. | |
| constexpr RawPointer | get () const noexcept |
| Retrieves underlying resource pointer. | |
| constexpr RawPointer | release () noexcept |
| Retrieves underlying resource pointer and clear this. | |
Additional Inherited Members | |
| Public Types inherited from SDL::ResourceBaseT< DatagramSocketRaw > | |
| using | RawPointer |
| The underlying raw pointer type. | |
| using | RawConstPointer |
| The underlying const raw pointer type. | |
| Protected Member Functions inherited from SDL::ResourceBaseT< DatagramSocketRaw > | |
| constexpr | ~ResourceBaseT ()=default |
| Destructor. | |
| constexpr ResourceBaseT & | operator= (const ResourceBaseT &)=default |
| Assignment operator. | |
An object that represents a datagram connection to another system.
This is meant to be an unreliable, packet-oriented connection, such as UDP.
Datagram sockets follow different rules than stream sockets. They are not a reliable stream of bytes but rather packets, they are not limited to talking to a single other remote system, they do not maintain a single "connection" that can be dropped, and they are more nimble about network failures at the expense of being more complex to use. What makes sense for your app depends entirely on what your app is trying to accomplish.
Generally the idea of a datagram socket is that you send data one chunk ("packet") at a time to any address you want, and it arrives whenever it gets there, even if later packets get there first, and maybe it doesn't get there at all, and you don't know when anything of this happens by default.
|
inlineexplicitconstexprnoexcept |
Constructs from raw DatagramSocket.
| resource | a DatagramSocketRaw to be wrapped. |
This assumes the ownership, call release() if you need to take back.