MCPcopy Create free account
hub / github.com/SOUI2/soui / AddClient

Method AddClient

demo/httpsvr/GenericServer.cpp:47–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45
46
47BOOL CGenericServer::AddClient(SOCKET s, char* ClientAddress, int port)
48{
49 GotConnection(ClientAddress, port);
50
51 STRVECT::iterator it;
52 it = find(Visitors.begin(), Visitors.end(), ClientAddress);
53 if(it == Visitors.end())
54 Visitors.push_back(ClientAddress);
55
56 InterlockedIncrement(&Stats.nTotalHits);
57
58 ThreadTag Thread;
59 HANDLE hThread;
60 unsigned int threadID;
61
62 EnterCriticalSection(&cs);
63 NewConnectionTag *NewConn = new NewConnectionTag;
64 NewConn->pGenericServer = this;
65 NewConn->s = s;
66 hThread = (HANDLE)_beginthreadex(NULL, 0, ClientThread, NewConn, 0, &threadID);
67 if(hThread)
68 {
69 Thread.threadID = threadID;
70 Thread.hThread = hThread;
71 ThreadList.push_back(Thread);
72 }
73 else
74 LogMessage(LOGFILENAME, _T("_beginthreadex(...) failure"), _T("AddClient"), errno);
75 LeaveCriticalSection(&cs);
76
77 return TRUE;
78}
79
80
81

Callers 1

AcceptThreadMethod · 0.80

Calls 4

findFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected