Rework for TLS.

This commit is contained in:
Brad Arant committed 2024-07-10 13:30:18 -07:00
1 parent 519faa535b
commit b7deabc5dc
2830 files changed
+4559 -80373

No files matched your search

+48 -2
View File
@@ -1,8 +1,9 @@
#ifndef __TCPSocket_h__
#define __TCPSocket_h__
#include "includes"
#include "Socket.h"
#include "TLS.h"
#include "IPAddress.h"
namespace core {
@@ -17,12 +18,13 @@ namespace core {
/// synchronous data connection.
///
class TCPSocket : public Socket {
class TCPSocket : public Socket, public TLS {
public:
TCPSocket(EPoll &ePoll);
TCPSocket(EPoll &ePoll, std::string text);
TCPSocket(EPoll &ePoll, SSL_CTX *ctx, std::string text);
virtual ~TCPSocket();
void connect(IPAddress &address);
@@ -38,6 +40,50 @@ namespace core {
virtual void output(std::stringstream &out);
///
/// Override this method to receive data directly from the socket as data is
/// received. If you need data split by line termination characters then
/// override the onLineReceived method instead.
///
virtual void onDataReceived(coreutils::ZString &data) override;
///
/// Override the onLineReceived method to receive a string of characters that
/// represents a single line of data terminated by a LF or CRLF. If onDataReceived
/// was overriden this method will not be called unless the onDataReceived calls
/// this method explicitly using the class and member name.
///
virtual void onLineReceived(coreutils::ZString &line);
///
/// Override the onBlockReceived method to receive a string of characters that
/// represents a single block of data of length determined by the block length value. If
/// onDataReceived was overriden this method will not be called unless the onDataReceived
/// calls this method explicitly using the class and member name.
///
virtual void onBlockReceived(coreutils::ZString &block);
///
/// Use setBlockSize to set the amount of data that should be read at once from the
/// session data buffer.
/// If this value is set to 0 then the data will be retrieved
///
void setBlockSize(int size = 0);
protected:
bool term = false;
private:
char *lineBuffer = NULL;
int lineBufferSize = 0;
int lineLength = 0;
int blockLength = 0;
int blockSize = 0;
};
}