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; }
SocketTcpServer* DviServerLpec::CreateServer(const NetworkAdapter& aNif) { SocketTcpServer* server = new SocketTcpServer(iDvStack.Env(), "LpecServer", iPort, aNif.Address()); const TUint numThreads = iDvStack.Env().InitParams()->DvNumLpecThreads(); AdapterData* ad = new AdapterData(aNif.Address()); iAdapterData.push_back(ad); for (TUint i=0; i<numThreads; i++) { Bws<Thread::kMaxNameBytes+1> thName; thName.AppendPrintf("LpecSession %d", i); thName.PtrZ(); DviSessionLpec* session = new DviSessionLpec(iDvStack, aNif.Address(), iPort); server->Add((const TChar*)thName.Ptr(), session); ad->iSessions.push_back(session); } return server; }
void OpenHome::TestFramework::Runner::Main(TInt /*aArgc*/, TChar* /*aArgv*/[], Net::InitialisationParams* aInitParams) { Net::UpnpLibrary::Initialise(aInitParams); // Debug::SetLevel(Debug::kNetwork); std::vector<NetworkAdapter*>* ifs = Os::NetworkListAdapters(false, "TestEcho"); ASSERT(ifs->size() > 0); TIpAddress addr = (*ifs)[0]->Address(); Endpoint endpt(0, addr); Endpoint::AddressBuf buf; endpt.AppendAddress(buf); for (TUint i=0; i<ifs->size(); i++) { (*ifs)[i]->RemoveRef("TestEcho"); } Print("Using network interface %s\n\n", buf.Ptr()); Semaphore sem("", 0); SocketTcpServer* server = new SocketTcpServer("ECHO", 1025, addr); server->Add("ECHO", new EchoSession(sem)); sem.Wait(); delete ifs; Net::UpnpLibrary::Close(); }
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); }