42 #include <visp/vpServer.h>
52 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
77 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
83 vpERROR_TRACE(
"vpServer::vpServer(const int &port_serv), cannot open socket." );
100 : adress(), port(0), started(false), max_clients(10)
104 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
110 vpERROR_TRACE(
"vpServer::vpServer(const std::string &adress_serv,const int &port_serv), cannot open socket." );
116 adress = adress_serv;
125 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
132 #
if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
135 closesocket( (
unsigned)
receptor_list[i].socketFileDescriptorReceptor );
148 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
157 std::cout <<
"Error id : " << bindResult << std::endl;
158 std::string errorMessage(
"vpServer::vpServer(), cannot bind to port" );
159 char posrtNumberString[32];
160 sprintf( posrtNumberString,
"%d", port );
162 errorMessage += posrtNumberString;
163 errorMessage +=
" The port may be already used.";
175 std::cout <<
"Failed to set socket signal option" << std::endl;
178 #endif // SO_NOSIGPIPE
180 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
186 std::cout <<
"Server ready" << std::endl;
234 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
240 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
248 printf(
"New client connected : %s\n", inet_ntoa(client.
receptorAddress.sin_addr));
257 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
258 int numbytes = recv(
receptor_list[i].socketFileDescriptorReceptor, &deco, 1, MSG_PEEK);
260 int numbytes = recv((
unsigned int)
receptor_list[i].socketFileDescriptorReceptor, &deco, 1, MSG_PEEK);
266 std::cout <<
"Disconnected : " << inet_ntoa(
receptor_list[i].receptorAddress.sin_addr) << std::endl;
fd_set readFileDescriptor
void print(const char *id="")
bool checkForConnections()
SOCKET socketFileDescriptorEmitter
struct sockaddr_in emitterAddress
std::vector< vpReceptor > receptor_list
SOCKET socketFileDescriptorReceptor
struct sockaddr_in receptorAddress