Example of a TCP client/server.
#include <iostream>
#include <visp3/core/vpServer.h>
int main()
{
#ifdef ENABLE_VISP_NAMESPACE
#endif
#ifdef VISP_HAVE_FUNC_INET_NTOP
try {
int port = 35000;
bool run = true;
int val;
while (run) {
if (serv.
receive(&val) !=
sizeof(
int))
std::cout << "Error while receiving" << std::endl;
else
std::cout << "Received : " << val << std::endl;
val = val + 1;
if (serv.
send(&val) !=
sizeof(
int))
std::cout << "Error while sending" << std::endl;
else
std::cout << "Sending : " << val << std::endl;
}
}
return EXIT_SUCCESS;
}
std::cout << "Catch an exception: " << e << std::endl;
return EXIT_FAILURE;
}
#else
std::cout << "This test doesn't work on win XP where inet_ntop() is not available" << std::endl;
return EXIT_SUCCESS;
#endif
}
error that can be emitted by ViSP classes.
int send(T *object, const int unsigned &sizeOfObject=sizeof(T))
int receive(T *object, const unsigned int &sizeOfObject=sizeof(T))
This class represents a Transmission Control Protocol (TCP) server.
unsigned int getNumberOfClients() const
bool checkForConnections()