summaryrefslogtreecommitdiff
path: root/networksystem/udp_socket.h
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /networksystem/udp_socket.h
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'networksystem/udp_socket.h')
-rw-r--r--networksystem/udp_socket.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/networksystem/udp_socket.h b/networksystem/udp_socket.h
new file mode 100644
index 0000000..8f7c88a
--- /dev/null
+++ b/networksystem/udp_socket.h
@@ -0,0 +1,45 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================
+
+#ifndef UDP_SOCKET_H
+#define UDP_SOCKET_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "tier1/netadr.h"
+#include "tier0/basetypes.h"
+
+class CUtlBuffer;
+
+// Creates a non-blocking UPD socket
+class CUDPSocket
+{
+public:
+ CUDPSocket();
+ ~CUDPSocket();
+
+ bool Init( unsigned short bindToPort );
+ void Shutdown();
+
+ bool RecvFrom( netadr_t& packet_from, CUtlBuffer& data );
+ bool SendTo( const netadr_t &recipient, const CUtlBuffer& data );
+ bool SendTo( const netadr_t &recipient, const byte *data, size_t datalength );
+
+ bool IsValid() const { return m_Socket != 0; }
+
+protected:
+ bool CreateSocket (void);
+
+ class CImpl;
+ CImpl *m_pImpl;
+
+ netadr_t m_socketIP;
+ unsigned int m_Socket;
+ unsigned short m_Port;
+};
+
+#endif // UDP_SOCKET_H