void CheesyVisionServer::Run() { cout << "Running Cheesy Vision Server" << endl; if (_listening == false) return; //Make sure we are listening SocketServerStreamProvider *sock; sock = new SocketServerStreamProvider(_listenPort); while (_listening) { try { IOStream *stream = sock->accept(); _lastHeartbeatTime = Timer::GetFPGATimestamp(); while (Timer::GetFPGATimestamp() < _lastHeartbeatTime + HEARTBEAT_TIMEOUT) { try { uint8_t byte; stream->read(&byte, 1); _curLeftStatus = (byte & (1 << 1)) > 0; _curRightStatus = (byte & (1 << 0)) > 0; UpdateCounts(_curLeftStatus,_curRightStatus); _lastHeartbeatTime = Timer::GetFPGATimestamp(); } catch (EOFException e) { //End of file, wait for a bit and read some more Wait(0.05); } } delete stream;//close, delete and recreate the stream } catch (IOException e) { printf("Socket IO error: %s\n", e.what()); //Catching this exception will dro } } Wait(0.05); delete sock; }