SockIt
Functions

TcpServer.cpp File Reference

#include "TcpServer.h"

Go to the source code of this file.

Functions

void socket_deallocate (tcp::socket *socket)

Function Documentation

void socket_deallocate ( tcp::socket *  socket)

Helper function to shutdown and deallocate the memory for a socket.

Parameters:
socketThe socket to deallocate.

Definition at line 138 of file TcpServer.cpp.

References Logger::error().

Referenced by TcpServer::start_listening().

{
    // may already have been deallocated
    if(!socket) return;

    try
    {
        if(socket && socket->is_open())
        {
            //s->shutdown(s->shutdown_both);
            socket->close();
        }
    }
    catch(boost::system::error_code &e)
    {
        Logger::error("socket deallocate: " + e.message());
    }
    catch(std::exception &er)
    {
        Logger::error("socket deallocate: " + std::string(er.what()));
    }

    delete socket;
    socket = 0;
}
 All Classes Files Functions Variables Typedefs Friends Defines