void* Client::startNetworkTrd(void* data) { client_data* clnt_data = (struct client_data *)data; Client* clnt = clnt_data->instance; const char* h = clnt_data->address; int port = clnt_data->port; RakNet::RakPeerInterface* inst = RakNet::RakPeerInterface::GetInstance(); inst->AllowConnectionResponseIPMigration(false); RakNet::Packet *packet; RakNet::SocketDescriptor sd(port + 100, 0); inst->Startup(1, &sd, 1); inst->Connect(h, port, 0, 0); clnt->setPeer(inst); //LOG(INFO) << "[Client]SOcket was configured..."; struct timespec req; req.tv_sec = 0; req.tv_nsec = 25000L; RakNet::RPC4 rpc; inst->AttachPlugin(&rpc); clnt->setRPC(&rpc); clnt->setRunning(true); while (clnt->getRunning()) { nanosleep(&req, NULL); for (packet = clnt->getPeer()->Receive(); packet; clnt->getPeer()->DeallocatePacket(packet), packet = clnt->getPeer()->Receive()) { clnt->getListener()->handle(packet); } } clnt->getPeer()->CloseConnection(*clnt->getServerAddr(), true); clnt->getPeer()->Shutdown(10.0); RakNet::RakPeerInterface::DestroyInstance(clnt->getPeer()); }