mtproto_tcp_socket.h 989 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. #include "mtproto/details/mtproto_abstract_socket.h"
  9. namespace MTP::details {
  10. class TcpSocket final : public AbstractSocket {
  11. public:
  12. TcpSocket(
  13. not_null<QThread*> thread,
  14. const QNetworkProxy &proxy,
  15. bool protocolForFiles);
  16. void connectToHost(const QString &address, int port) override;
  17. bool isGoodStartNonce(bytes::const_span nonce) override;
  18. void timedOut() override;
  19. bool isConnected() override;
  20. bool hasBytesAvailable() override;
  21. int64 read(bytes::span buffer) override;
  22. void write(bytes::const_span prefix, bytes::const_span buffer) override;
  23. int32 debugState() override;
  24. QString debugPostfix() const override;
  25. private:
  26. void handleError(int errorCode);
  27. QTcpSocket _socket;
  28. };
  29. } // namespace MTP::details