1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Add UDP listen socket and IP address wrapper.

This commit is contained in:
Bartosz Taudul
2019-06-17 19:23:43 +02:00
parent de058d2a0d
commit e0bbb41976
2 changed files with 154 additions and 0 deletions
+43
View File
@@ -3,6 +3,8 @@
#include <functional>
struct sockaddr;
namespace tracy
{
@@ -83,6 +85,47 @@ private:
int m_sock;
};
class IpAddress
{
public:
IpAddress();
~IpAddress();
void Set( const struct sockaddr& addr );
uint32_t GetNumber() const { return m_number; }
const char* GetText() const { return m_text; }
IpAddress( const IpAddress& ) = delete;
IpAddress( IpAddress&& ) = delete;
IpAddress& operator=( const IpAddress& ) = delete;
IpAddress& operator=( IpAddress&& ) = delete;
private:
uint32_t m_number;
char m_text[17];
};
class UdpListen
{
public:
UdpListen();
~UdpListen();
bool Listen( int port );
void Close();
const char* Read( int& len, IpAddress& addr );
UdpListen( const UdpListen& ) = delete;
UdpListen( UdpListen&& ) = delete;
UdpListen& operator=( const UdpListen& ) = delete;
UdpListen& operator=( UdpListen&& ) = delete;
private:
int m_sock;
};
}
#endif