Exemplo n.º 1
0
echoConnection::echoConnection( const net::LocalEndpointR& local, unsigned short timeout )
{
	net::ConnectionEndpoint::ConnectionType type = local->type();

	switch ( type )	{
		case net::ConnectionEndpoint::UDP:
			LOG_FATAL << "UDP local connection type not implemented";
			abort();

		case net::ConnectionEndpoint::TCP:	{
			const net::LocalTCPendpoint* lcl = static_cast<const net::LocalTCPendpoint*>( local.get() );
			LOG_TRACE << "Created connection handler for " << lcl->toString();
			break;
		}
#ifdef WITH_SSL
		case net::ConnectionEndpoint::SSL:	{
			const net::LocalSSLendpoint* lcl = static_cast<const net::LocalSSLendpoint*>( local.get() );
			LOG_TRACE << "Created connection handler (SSL) for " << lcl->toString();
			break;
		}
#else
		case net::ConnectionEndpoint::SSL:
#endif // WITH_SSL
		default:
			LOG_FATAL << "Impossible local connection type !";
			abort();
	}

	m_state = NEW;
	m_dataStart = NULL;
	m_dataSize = 0;
	m_idleTimeout = timeout;
}
Exemplo n.º 2
0
MainConnectionHandler::MainConnectionHandler( const net::LocalEndpointR& local)
	:m_localEndPoint(local)
	,m_input(0)
	,m_inputsize(0)
	,m_output(0)
	,m_outputsize(0)
	,m_terminated(false)
	,m_exceptionByeMessagePtr(0)
{
	m_input = (char*)std::malloc( NeworkBufferSize);
	m_output = (char*)std::malloc( NeworkBufferSize);
	if (!m_input || !m_output)
	{
		if (m_input) std::free( m_input);
		if (m_output) std::free( m_output);
		throw std::bad_alloc();
	}
	LOG_TRACE << "Created connection handler for " << local->toString();
}
Exemplo n.º 3
0
Connection::Connection( const net::LocalEndpointR& local, unsigned int inputBufferSize, unsigned int outputBufferSize)
{
	data = new Private( inputBufferSize, outputBufferSize);
	LOG_TRACE << "Created connection handler for " << local->toString();
}
Exemplo n.º 4
0
wolframeConnection::wolframeConnection( const WolframeHandler& context,
					const net::LocalEndpointR& local )
	: m_globalCtx( context ),
	  m_input(0), m_inputsize(16536), /*m_inputpos(0),*/ m_output(0), m_outputsize( 4096 ), m_execContext( &context.proc(), &context.aaaa())
{
	m_input = std::malloc( m_inputsize);
	m_output = std::malloc( m_outputsize);
	if (!m_input || !m_output)
	{
		if (m_input) std::free( m_input);
		if (m_output) std::free( m_output);
		throw std::bad_alloc();
	}
	net::ConnectionEndpoint::ConnectionType type = local->type();
	std::string protocol;
	if (local->config().protocol.empty())
	{
		protocol = "wolframe";
	}
	else
	{
		protocol = local->config().protocol;
	}
	m_protocolHandler.reset( m_execContext.provider()->protocolHandler( protocol));
	if (!m_protocolHandler.get())
	{
		LOG_FATAL << "protocol '" << protocol << "' is not known (protocol module not loaded)";
		abort();
	}
	switch ( type )	{
		case net::ConnectionEndpoint::UDP:
			LOG_FATAL << "UDP local connection type not implemented";
			abort();

		case net::ConnectionEndpoint::TCP:	{
			m_localEP = local;
			LOG_TRACE << "Created connection handler for " << m_localEP->toString();
			break;
		}
#ifdef WITH_SSL
		case net::ConnectionEndpoint::SSL:	{
			m_localEP = local;
			LOG_TRACE << "Created connection handler (SSL) for " << m_localEP->toString();
			break;
		}
#else
		case net::ConnectionEndpoint::SSL:
#endif // WITH_SSL
		default:
			LOG_FATAL << "Impossible local connection type !";
			abort();
	}

	// Initialize channel data to start-up values
	m_state = NEW_CONNECTION;
	m_dataStart = NULL;
	m_dataSize = 0;

	m_authentication = NULL;
	m_authorization = NULL;
	m_audit = NULL;
	m_protocolHandler->setInputBuffer( m_input, m_inputsize);
	m_protocolHandler->setOutputBuffer( m_output, m_outputsize, 0);
	m_protocolHandler->setExecContext( &m_execContext);
	m_protocolHandler->setLocalEndPoint( m_localEP);
}