this is an example for a network server
- Author
- MIP
#ifdef WIN32
#include <windows.h>
#endif
#ifndef WIN32
#include <unistd.h>
#endif
#include <NetworkComm/CScommServer.hh>
#include <Base/Common/W32Compat.hh>
using namespace std;
int main (int , char** )
{
vector<float> floats;
floats.push_back(-3);
floats.push_back(-2);
floats.push_back(-1);
string msg="LPOSHEAD";
msg="RPOSHEAD";
vector<int> ints,intMsg;
intMsg.push_back(-5);
intMsg.push_back(+6);
vector<float> recFloats;
std::vector<char> binData(8);
binData[0]=']';
binData[1]='b';
binData[2]='i';
binData[3]='n';
binData[4]='a';
binData[5]='r';
binData[6]='y';
binData[7]='[';
bool endless=true;
while (endless) {
msg="LPOSHEAD";
if (server.
GetData(msg, recFloats)==0) {
cout<<"New Data from client:"<<endl;
for (unsigned int i=0;i<recFloats.size();i++)
cout<<recFloats[i]<<" ";
cout<<endl;
}
biassleep(1);
msg="RPOSHEAD";
if (server.
GetData(msg, ints)==0) {
cout<<"New Data from client:"<<endl;
for (unsigned int i=0;i<ints.size();i++)
cout<<ints[i]<<" ";
cout<<endl;
}
server.
SendMsg(
"exampleClient",
"BINDATA",&binData[0],binData.size());
}
}