| 45 | |
| 46 | |
| 47 | BOOL 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 |
no test coverage detected