Team Fortress 2 Source Code as on 22/4/2020
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.

39 lines
860 B

  1. //========= Copyright 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. };
  28. #endif // BLOCKINGUDPSOCKET_H