Socket.h 602 B

1234567891011121314151617181920212223242526272829
  1. #ifndef SOCKET_H
  2. #define SOCKET_H
  3. #include "common/utils/Types.h"
  4. enum WaitResult {
  5. TIMEOUT, SUCCESS, ERROR
  6. };
  7. class Socket final {
  8. public:
  9. Socket();
  10. ~Socket();
  11. Socket(const Socket& other) = delete;
  12. Socket& operator=(const Socket& other) = delete;
  13. Socket(Socket&& other) = delete;
  14. Socket& operator=(Socket&& other) = delete;
  15. bool hasError() const;
  16. bool setNonLinger();
  17. bool listenOnPort(u16 port, uint queueLength) const;
  18. WaitResult waitForConnection(uint timeoutMillis) const;
  19. int acceptConnection() const;
  20. private:
  21. int socketId;
  22. };
  23. #endif