MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / CreateTCPEchoServer

Function CreateTCPEchoServer

test/clsocket/RecvAsync.cpp:25–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23};
24
25void *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
55int main(int argc, char **argv)
56{

Callers

nothing calls this directly

Calls 9

sleepFunction · 0.85
ListenMethod · 0.80
ReceiveMethod · 0.80
GetDataMethod · 0.80
GetBytesReceivedMethod · 0.80
InitializeMethod · 0.45
AcceptMethod · 0.45
SendMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected