Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1017 B

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef BLOCKINGUDPSOCKET_H
  7. #define BLOCKINGUDPSOCKET_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "netadr.h"
  12. class CBlockingUDPSocket
  13. {
  14. public:
  15. explicit CBlockingUDPSocket();
  16. virtual ~CBlockingUDPSocket();
  17. bool WaitForMessage( float timeOutInSeconds );
  18. unsigned int ReceiveSocketMessage( struct sockaddr_in *packet_from, unsigned char *buf, size_t bufsize );
  19. bool SendSocketMessage( const struct sockaddr_in& rRecipient, const unsigned char *buf, size_t bufsize );
  20. bool IsValid() const { return m_Socket != 0; }
  21. protected:
  22. bool CreateSocket (void);
  23. class CImpl;
  24. CImpl *m_pImpl;
  25. netadr_t m_cserIP;
  26. unsigned int m_Socket;
  27. private:
  28. CBlockingUDPSocket( const CBlockingUDPSocket& ); // = delete
  29. CBlockingUDPSocket& operator= ( const CBlockingUDPSocket& ); // = delete
  30. };
  31. #endif // BLOCKINGUDPSOCKET_H