Improve memory management

This commit is contained in:
2025-08-16 09:13:07 -04:00
parent 1da824d8cb
commit aef2d050f5
5 changed files with 82 additions and 8 deletions

View File

@@ -2,17 +2,36 @@
#include <common/utility.hpp>
#include <common/stringbuffer.hpp>
SocketConnectionReceiver::SocketConnectionReceiver()
: mSocket(-1), mIsRunnable(true)
{
}
/// @brief After a connection has been accepted the SocketConnectionReceiver is initialized with the incoming socket
/// @param socket
/// @param internalSocketAddress
SocketConnectionReceiver::SocketConnectionReceiver(int socket, sockaddr_in internalSocketAddress)
: mSocket(socket), mInternalSocketAddress(internalSocketAddress)
: mSocket(socket), mInternalSocketAddress(internalSocketAddress), mIsRunnable(true)
{
}
/// @brief Initialize a SocketConnectionReceiver.
/// @param socket
/// @param internalSocketAddress
void SocketConnectionReceiver::initialize(int socket, sockaddr_in internalSocketAddress)
{
close();
mSocket=socket;
mInternalSocketAddress = internalSocketAddress;
}
/// @brief The destructor will close the socket
SocketConnectionReceiver::~SocketConnectionReceiver()
{
{
isRunnable(false);
close();
}
@@ -31,7 +50,7 @@ void SocketConnectionReceiver::close(void)
void SocketConnectionReceiver::threadFunction(int data)
{
String line;
while(true)
while(mIsRunnable)
{
readLine(line);
if(0==line.length())