| 23 | }; |
| 24 | |
| 25 | void *CreateTCPEchoServer(void *param) |
| 26 | { |
| 27 | CPassiveSocket socket; |
| 28 | CActiveSocket *pClient = NULL; |
| 29 | struct thread_data *pData = (struct thread_data *)param; |
| 30 | int nBytesReceived = 0; |
| 31 | |
| 32 | socket.Initialize(); |
| 33 | socket.Listen(pData->pszServerAddr, pData->nPort); |
| 34 | |
| 35 | if ((pClient = socket.Accept()) != NULL) |
| 36 | { |
| 37 | while (nBytesReceived != pData->nTotalPayloadSize) |
| 38 | { |
| 39 | if (nBytesReceived += pClient->Receive(pData->nNumBytesToReceive)) |
| 40 | { |
| 41 | pClient->Send((const uint8 *)pClient->GetData(), pClient->GetBytesReceived()); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | sleep(100); |
| 46 | |
| 47 | delete pClient; |
| 48 | } |
| 49 | |
| 50 | socket.Close(); |
| 51 | |
| 52 | return NULL; |
| 53 | } |
| 54 | |
| 55 | int main(int argc, char **argv) |
| 56 | { |
nothing calls this directly
no test coverage detected