本文整理汇总了C++中IOStream::read方法的典型用法代码示例。如果您正苦于以下问题:C++ IOStream::read方法的具体用法?C++ IOStream::read怎么用?C++ IOStream::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOStream
的用法示例。
在下文中一共展示了IOStream::read方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Run
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;
}