Exemplo n.º 1
0
SocketTcpServer* DviServerUpnp::CreateServer(const NetworkAdapter& aNif)
{
    SocketTcpServer* server = new SocketTcpServer("DSVU", iPort, aNif.Address());
    TChar thName[5];
    const TUint numWsThreads = Stack::InitParams().DvNumServerThreads();
    for (TUint i=0; i<numWsThreads; i++) {
        (void)sprintf(&thName[0], "DS%2lu", (unsigned long)i);
        server->Add(&thName[0], new DviSessionUpnp(aNif.Address(), server->Port(), *this));
    }
    return server;
}
Exemplo n.º 2
0
void SuiteTcpServerShutdown::Test()
{
    SocketTcpServer *server;

    // server thread priority > main thread priority - no sessions open
    server = new SocketTcpServer("TSSX", 0, iInterface, kPriorityNormal + kPriorityMore);
    server->Add("TSS1", new TcpSessionTest());
    server->Add("TSS2", new TcpSessionTest());
    delete server;
    Thread::Sleep(500);
    TEST(1==1);

    if (!Thread::SupportsPriorities()) {
        // no point in repeating the same test for varying priorities if we don't support priorities
        return;
    }

    server = new SocketTcpServer("TSSX", 0, iInterface, kPriorityNormal + kPriorityLess);
    server->Add("TSS1", new TcpSessionTest());
    server->Add("TSS2", new TcpSessionTest());
    delete server;
    Thread::Sleep(500);
    TEST(1==1);

    // server thread priority == main thread priority - no sessions open
    server = new SocketTcpServer("TSSX", 0, iInterface, kPriorityNormal);
    server->Add("TSS1", new TcpSessionTest());
    server->Add("TSS2", new TcpSessionTest());
    delete server;
    Thread::Sleep(500);
    TEST(1==1);


    // server thread priority > main thread priority - one session open
    server = new SocketTcpServer("TSSX", 0, iInterface, kPriorityNormal + kPriorityMore);
    server->Add("TSS1", new TcpSessionTest());
    server->Add("TSS2", new TcpSessionTest());

    SocketTcpClient client1;
    client1.Open();
    client1.Connect(Endpoint(1995, iInterface), 1000);
    delete server;
    Thread::Sleep(500);
    client1.Close();
    TEST(1==1);

    // server thread priority < main thread priority - one session open
    server = new SocketTcpServer("TSSX", 0, iInterface, kPriorityNormal + kPriorityLess);
    server->Add("TSS1", new TcpSessionTest());
    server->Add("TSS2", new TcpSessionTest());
    SocketTcpClient client2;
    client2.Open();
    client2.Connect(Endpoint(server->Port(), iInterface), 1000);
    delete server;
    Thread::Sleep(500);
    client2.Close();
    TEST(1==1);

    // server thread priority == main thread priority - one session open
    server = new SocketTcpServer("TSSX", 0, iInterface, kPriorityNormal);
    server->Add("TSS1", new TcpSessionTest());
    server->Add("TSS2", new TcpSessionTest());
    SocketTcpClient client3;
    client3.Open();
    client3.Connect(Endpoint(server->Port(), iInterface), 1000);
    delete server;
    Thread::Sleep(500);
    client3.Close();
    TEST(1==1);
}