void *UdpServer::startUdpServerThread(void *ptr) { int sock = ((UdpServer*)ptr)->getSock(); struct sockaddr_in sender; sender.sin_family = AF_INET; socklen_t sendsize = sizeof(sender); bzero(&sender, sizeof(sender)); connection_t * connection; cout << "server gestartet!" << endl; while (((UdpServer *)ptr)->getIsActive()) { cout << "warte auf Broadcast..." << endl; connection = (connection_t *)malloc(sizeof(connection_t)); NetworkMessage incomingMessage(LOGINREQUEST); connection->sock = recvfrom(sock,&incomingMessage,sizeof(NetworkMessage),0,(struct sockaddr*)&sender, &sendsize); if (connection->sock <= 0){ free(connection); } else{ cout << "Verbindungen eingegangen(UDP)..SOCK: " << connection->sock << endl; processThread((struct sockaddr_in)sender,ptr,incomingMessage); //close(connection->sock); free(connection); } cout << "Boradcast eigegangen!" << endl; } pthread_exit((void*) true); }
/* * Per-thread execution. Called for main thread and helper threads. */ static void threadMain(void *data, MprThread *tp) { MprCtx ctx; ctx = (tp) ? (MprCtx) tp : (MprCtx) mpr; processThread(ctx); finishThread(tp); }