38 lines
726 B
C++
38 lines
726 B
C++
#pragma once
|
|
|
|
#include <chrono>
|
|
#include <string>
|
|
|
|
#include "usenetsearch/Except.h"
|
|
#include "usenetsearch/IoSocket.h"
|
|
|
|
namespace usenetsearch {
|
|
|
|
struct SocketException: public UsenetSearchException
|
|
{
|
|
SocketException(int errorCode, const std::string& message):
|
|
UsenetSearchException(errorCode, message){}
|
|
|
|
virtual ~SocketException() = default;
|
|
};
|
|
|
|
class TcpConnection: public IoSocket
|
|
{
|
|
|
|
int m_fd{0};
|
|
|
|
public:
|
|
|
|
virtual ~TcpConnection();
|
|
|
|
void Connect(const std::string& host, std::uint16_t port);
|
|
void Disconnect();
|
|
int FileDescriptor() const;
|
|
virtual std::string Read(size_t amount) override;
|
|
virtual void Write(const std::string& data) override;
|
|
|
|
};
|
|
|
|
|
|
} // namespace usenetsearch
|