38 #include <visp3/core/vpServer.h>
48 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
73 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
79 vpERROR_TRACE(
"vpServer::vpServer(const int &port_serv), cannot open socket." );
96 : adress(), port(0), started(false), max_clients(10)
100 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
106 vpERROR_TRACE(
"vpServer::vpServer(const std::string &adress_serv,const int &port_serv), cannot open socket." );
112 adress = adress_serv;
121 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
128 #
if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
131 closesocket( (
unsigned)
receptor_list[i].socketFileDescriptorReceptor );
144 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
153 std::cout <<
"Error id : " << bindResult << std::endl;
154 std::string errorMessage(
"vpServer::vpServer(), cannot bind to port" );
155 char posrtNumberString[32];
156 sprintf( posrtNumberString,
"%d", port );
158 errorMessage += posrtNumberString;
159 errorMessage +=
" The port may be already used.";
171 std::cout <<
"Failed to set socket signal option" << std::endl;
174 #endif // SO_NOSIGPIPE
176 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
182 std::cout <<
"Server ready" << std::endl;
230 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
236 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
244 printf(
"New client connected : %s\n", inet_ntoa(client.
receptorAddress.sin_addr));
253 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
254 int numbytes = recv(
receptor_list[i].socketFileDescriptorReceptor, &deco, 1, MSG_PEEK);
256 int numbytes = recv((
unsigned int)
receptor_list[i].socketFileDescriptorReceptor, &deco, 1, MSG_PEEK);
262 std::cout <<
"Disconnected : " << inet_ntoa(
receptor_list[i].receptorAddress.sin_addr) << std::endl;
socklen_t receptorAddressSize
fd_set readFileDescriptor
int socketFileDescriptorEmitter
void print(const char *id="")
bool checkForConnections()
int socketFileDescriptorReceptor
struct sockaddr_in emitterAddress
std::vector< vpReceptor > receptor_list
struct sockaddr_in receptorAddress