this is an example for a network client
- Author
- MIP
#ifdef WIN32
#include <windows.h>
#endif
#ifndef WIN32
#include <unistd.h>
#endif
#include <Base/Common/W32Compat.hh>
#include <NetworkComm/CScommClient.hh>
#include <cstdlib>
using namespace std;
int main (int argc, char* argv[])
{
if (argc<2) {
cout<<"usage:"<<argv[0]<<" serverName"<<endl;
exit(0);
}
client.
SetName(
string(
"exampleClient"));
string msg="RPOSHEAD";
cout<<"Connection returned:"<<
vector<float> floats;
floats.push_back(0.1f);
floats.push_back(0.2f);
vector<int> ints;
ints.push_back(-123);
floats.push_back(0.4f);
std::vector<char> binData;
floats.resize(1);
bool endlessLoop=true;
while (endlessLoop)
{
biassleep(1);
if (client.
GetData(msg, floats)==0) {
cout<<"New Data from server:"<<endl;
for (unsigned int i=0;i<floats.size();i++)
cout<<floats[i]<<" ";
cout<<endl;
}
if (client.
GetData(
"BINDATA", binData)==0) {
cout<<"New binary Data from server:"<<endl;
for (unsigned int i=0;i<binData.size();i++)
cout<<binData[i];
cout<<endl;
}
}
}