try
{
//Are we created?
if (m_bCreated)
{
//Report it
ReportError("Relay","Already created!");
//Exit
return FALSE;
}
//Create the socket
m_pSocket=new CAcceptSocket(this);
//Protect it
std::auto_ptr<CAcceptSocket> pProtection(m_pSocket);
//Try to create it
if (!m_pSocket->Create())
{
//Report it
ReportError("Relay","Failed to create socket!");
//Exit
return FALSE;
}
//Try to bind it
if (!m_pSocket->Bind(aBindAddress,
usBindPort))
{
//Report it
ReportError("Relay","Failed to create socket!");
//Exit
return FALSE;
}
//Save the data
m_aTarget=aDestinationAddress;
m_usTargetPort=usDestinationPort;
m_aBindAddress=aBindAddress;
//Try to listen
if (!m_pSocket->Listen())
{
//Report it
ReportError("Relay","Failed to listen!");
//Exit
return FALSE;
}
//Remove protection
pProtection.release();
//We are done
m_bCreated=TRUE;
//Done
return TRUE;
}
ERROR_HANDLER_RETURN("Relay",FALSE)