// used by non-threaded version static void handleIsoConnectionsThreadless(IsoServer self) { Socket connectionSocket; if ((connectionSocket = ServerSocket_accept((ServerSocket) self->serverSocket)) != NULL) { #if (CONFIG_MAXIMUM_TCP_CLIENT_CONNECTIONS != -1) if (private_IsoServer_getConnectionCounter(self) >= CONFIG_MAXIMUM_TCP_CLIENT_CONNECTIONS) { if (DEBUG_ISO_SERVER) printf("ISO_SERVER: maximum number of connections reached -> reject connection attempt.\n"); Socket_destroy(connectionSocket); handleClientConnections(self); return; } #endif IsoConnection isoConnection = IsoConnection_create(connectionSocket, self); private_IsoServer_increaseConnectionCounter(self); addClientConnection(self, isoConnection); self->connectionHandler(ISO_CONNECTION_OPENED, self->connectionHandlerParameter, isoConnection); } handleClientConnections(self); }
MessageInterface* ComManager::getMessage() { if (current_connection != 0) { delete current_connection; current_connection = 0; } if (messages.empty()) { readSockets(); } if(!messages.empty()) { current_connection = new MessageContainer(messages.front().getSocket(),messages.front().getMessage()); messages.pop(); if (utility->validHeader(current_connection->getMessage())) { MessageInterface* msg = utility->buildIncomingMessage(current_connection->getMessage(),true); if(msg->getHeader()->getMsgType()!=Msg::VERSIONING) addClientConnection(msg->getHeader()->getClientID()); return msg; } else { Message<StatusAndError>* return_msg = new Message<StatusAndError>(CommonHeader(Msg::STATUS_AND_ERROR,Msg::Sub::UNKNOWN,0,0), StatusAndError(Status::MESSAGE_CORRUPTED,Msg::UNKNOWN,Msg::Sub::UNKNOWN,"Corrupted Message")); sendMessage(return_msg); delete return_msg; return 0; } } else return 0; }