11 |
|
|
12 |
void TcpServerClass::OnAccept(int nErrorCode) |
void TcpServerClass::OnAccept(int nErrorCode) |
13 |
{ |
{ |
14 |
Accept(TcpClient); |
typedef std::list<TcpClientClass*>::iterator ClientIt; |
15 |
|
|
16 |
|
TcpClientClass* client = new TcpClientClass; |
17 |
|
Accept(*client); |
18 |
CSocket::OnAccept(nErrorCode); |
CSocket::OnAccept(nErrorCode); |
19 |
|
|
20 |
|
mClients.push_back(client); |
21 |
|
|
22 |
|
for (ClientIt it = mClients.begin(); it != mClients.end(); it++) |
23 |
|
{ |
24 |
|
if ( (*it)->isClosed ) |
25 |
|
{ |
26 |
|
delete (*it); |
27 |
|
mClients.erase(it); |
28 |
|
//efter erase er iteratoren ikke længere valid |
29 |
|
it = mClients.begin(); |
30 |
|
} |
31 |
|
} |
32 |
|
|
33 |
} |
} |