SockStream: runtime error while streaming from UDP socket
Posted: 17 Jul 2015, 10:59
I'm trying to use the BCI2000 to control a small robotic arm. I need to read the classifier from the BCI into a C++ program. So the ConnectorOutputAddress has been set to localhost:5051 and I'm using the example code from the App Connector page, which uses the SockStream class to read from a UDP socket. The code is as follows with the link to the wiki page:
http://www.bci2000.org/wiki/index.php/T ... _Connector
I have the BCI2000 running, but when I run this code I get the following error:
The error occurs at getline( connector, line ), and can be traced back to the following function in the SockStream class which reads the size of the incoming stream:
Any help would be much appreciated.
Code: Select all
#include "stdafx.h"
#include <iostream>
#include "SockStream.h"
using namespace std;
int main( int argc, char** argv )
{
const char* address = "localhost:5051";
if( argc > 1 )
address = argv[ 1 ];
receiving_udpsocket socket( address );
sockstream connection( socket );
string line;
// Print each line of BCI2000 input to stdout.
while( getline( connection, line ) )
//cout << line << endl;
return 0;
}I have the BCI2000 running, but when I run this code I get the following error:
Code: Select all
'ReadOutput.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll'
'ReadOutput.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll'
'ReadOutput.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll'
'ReadOutput.exe': Loaded 'C:\Windows\SysWOW64\WSHTCPIP.DLL'
First-chance exception at 0x75a1c42d in ReadOutput.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0040f4f4..Code: Select all
streamsize
streambuf::read( char* p, streamsize n )
{
if( n < 1 )
return 0;
streamsize r = on_read( p, n );
if( r < 0 )
throw std::runtime_error( "Read failure" );
m_read += r;
return r;
}