Throw exception instead of failing with SIGSEGV

This commit is contained in:
Ivan Savenko
2023-12-17 19:44:45 +02:00
parent dd88220b7c
commit 84d9078bd9
+6
View File
@@ -148,6 +148,9 @@ void CConnection::flushBuffers()
if(!enableBufferedWrite)
return;
if (!socket)
throw std::runtime_error("Can't write to closed socket!");
try
{
asio::write(*socket, connectionBuffers->writeBuffer);
@@ -164,6 +167,9 @@ void CConnection::flushBuffers()
int CConnection::write(const void * data, unsigned size)
{
if (!socket)
throw std::runtime_error("Can't write to closed socket!");
try
{
if(enableBufferedWrite)