Beispiel #1
0
HttpServer::HttpServer() : QTcpServer(), ThreadPool("HTTP")
{
    setMaxPendingConnections(20);
    InitializeThreads();

    // ----------------------------------------------------------------------
    // Build Platform String
    // ----------------------------------------------------------------------

#ifdef USING_MINGW
    g_sPlatform = QString( "Windows %1.%1" )
        .arg(LOBYTE(LOWORD(GetVersion())))
        .arg(HIBYTE(LOWORD(GetVersion())));
#else
    struct utsname uname_info;

    uname( &uname_info );

    g_sPlatform = QString( "%1 %2" ).arg( uname_info.sysname )
                                    .arg( uname_info.release );
#endif

    // ----------------------------------------------------------------------
    // Initialize Share Path
    // ----------------------------------------------------------------------

    m_sSharePath = GetShareDir();
    VERBOSE(VB_UPNP, QString( "HttpServer() - SharePath = %1")
            .arg(m_sSharePath));

    // -=>TODO: Load Config XML
    // -=>TODO: Load & initialize - HttpServerExtensions
}
Beispiel #2
0
void Network::Initialize()
{
	WSADATA wsa;
	if (WSAStartup(MAKEWORD(2, 2), &wsa) != 0)
	{
		printf("Failed. Error Code : %d", WSAGetLastError());
		exit(EXIT_FAILURE);
	}

	if ((socketThis = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == SOCKET_ERROR)
	{
		printf("Could not create socket : %d", WSAGetLastError());
		exit(EXIT_FAILURE);
	}
	threadsRunning = true;

	memset((char *)&localConnection.socketAddr, 0, sizeof(localConnection.socketAddr));
	localConnection.socketAddr.sin_family = AF_INET;
	localConnection.socketAddr.sin_addr.s_addr = INADDR_ANY;
	if (server)
	{
		InitializeServer();
	}
	else
	{
		InitializeClient();
	}

	InitializeThreads();
}
Beispiel #3
0
void ThreadPool::AddThread()
{
    if(((icurr_thread_num_*ADD_FACTOR) < command_.size())
            && (MAX_THREAD_NUM != icurr_thread_num_))
    {
        InitializeThreads();
        icurr_thread_num_ += THREAD_NUM;
    }
}
Beispiel #4
0
HttpServer::HttpServer() : QTcpServer(), ThreadPool("HTTP")
{
    setMaxPendingConnections(20);
    InitializeThreads();

    // ----------------------------------------------------------------------
    // Build Platform String
    // ----------------------------------------------------------------------

#ifdef USING_MINGW
    g_sPlatform = QString( "Windows %1.%2" )
        .arg(LOBYTE(LOWORD(GetVersion())))
        .arg(HIBYTE(LOWORD(GetVersion())));
#else
    struct utsname uname_info;

    uname( &uname_info );

    g_sPlatform = QString( "%1 %2" ).arg( uname_info.sysname )
                                    .arg( uname_info.release );
#endif

    // ----------------------------------------------------------------------
    // Initialize Share Path
    // ----------------------------------------------------------------------

    m_sSharePath = GetShareDir();
    VERBOSE(VB_UPNP, QString( "HttpServer() - SharePath = %1")
            .arg(m_sSharePath));

    // ----------------------------------------------------------------------
    // The HtmlServer Extension is our fall back if a request isn't processed
    // by any other extension.  (This is needed here since it listens for
    // '/' as it's base url ).
    // ----------------------------------------------------------------------

    m_pHtmlServer = new HtmlServerExtension( m_sSharePath );


    // -=>TODO: Load Config XML
    // -=>TODO: Load & initialize - HttpServerExtensions
}
Beispiel #5
0
HttpServer::HttpServer( int nPort ) 
          : QServerSocket( nPort, 20 ), //5),
            ThreadPool( "HTTP" )
{
    m_extensions.setAutoDelete( true );

    InitializeThreads();

    // ----------------------------------------------------------------------
    // Build Platform String
    // ----------------------------------------------------------------------

#ifdef USING_MINGW
    g_sPlatform = QString( "Windows %1.%1" )
        .arg(LOBYTE(LOWORD(GetVersion())))
        .arg(HIBYTE(LOWORD(GetVersion())));
#else
    struct utsname uname_info;

    uname( &uname_info );

    g_sPlatform = QString( "%1 %2" ).arg( uname_info.sysname )
                                    .arg( uname_info.release );
#endif

    // ----------------------------------------------------------------------
    // Initialize Share Path
    // ----------------------------------------------------------------------

    m_sSharePath = gContext->GetShareDir();
    VERBOSE( VB_UPNP, QString( "HttpServer( %1 ) - SharePath = %2" )
                      .arg( nPort ).arg( m_sSharePath ));


    // -=>TODO: Load Config XML
    // -=>TODO: Load & initialize - HttpServerExtensions
}