Visual Servoing Platform
version 3.1.0
|
#include <visp3/core/vpServer.h>
Public Member Functions | |
vpServer () | |
vpServer (const int &port) | |
vpServer (const std::string &adress_serv, const int &port_serv) | |
virtual | ~vpServer () |
bool | checkForConnections () |
bool | isStarted () |
unsigned int | getMaxNumberOfClients () |
unsigned int | getNumberOfClients () |
void | print () |
bool | start () |
void | setMaxNumberOfClients (unsigned int &l) |
void | addDecodingRequest (vpRequest *) |
int | getReceptorIndex (const char *name) |
std::string | getRequestIdFromIndex (const int &ind) |
unsigned int | getMaxSizeReceivedMessage () |
void | print (const char *id="") |
template<typename T > | |
int | receive (T *object, const unsigned int &sizeOfObject=sizeof(T)) |
template<typename T > | |
int | receiveFrom (T *object, const unsigned int &receptorEmitting, const unsigned int &sizeOfObject=sizeof(T)) |
std::vector< int > | receiveRequest () |
std::vector< int > | receiveRequestFrom (const unsigned int &receptorEmitting) |
int | receiveRequestOnce () |
int | receiveRequestOnceFrom (const unsigned int &receptorEmitting) |
std::vector< int > | receiveAndDecodeRequest () |
std::vector< int > | receiveAndDecodeRequestFrom (const unsigned int &receptorEmitting) |
int | receiveAndDecodeRequestOnce () |
int | receiveAndDecodeRequestOnceFrom (const unsigned int &receptorEmitting) |
void | removeDecodingRequest (const char *) |
template<typename T > | |
int | send (T *object, const int unsigned &sizeOfObject=sizeof(T)) |
template<typename T > | |
int | send (T *object, const unsigned int &sizeOfObject) |
template<typename T > | |
int | sendTo (T *object, const unsigned int &dest, const unsigned int &sizeOfObject=sizeof(T)) |
int | sendRequest (vpRequest &req) |
int | sendRequestTo (vpRequest &req, const unsigned int &dest) |
int | sendAndEncodeRequest (vpRequest &req) |
int | sendAndEncodeRequestTo (vpRequest &req, const unsigned int &dest) |
void | setMaxSizeReceivedMessage (const unsigned int &s) |
void | setTimeoutSec (const long &sec) |
void | setTimeoutUSec (const long &usec) |
void | setVerbose (const bool &mode) |
Protected Attributes | |
vpEmitter | emitter |
std::vector< vpReceptor > | receptor_list |
fd_set | readFileDescriptor |
int | socketMax |
std::vector< vpRequest * > | request_list |
unsigned int | max_size_message |
std::string | separator |
std::string | beginning |
std::string | end |
std::string | param_sep |
std::string | currentMessageReceived |
struct timeval | tv |
long | tv_sec |
long | tv_usec |
bool | verboseMode |
This class represents a Transmission Control Protocol (TCP) server.
TCP provides reliable, ordered delivery of a stream of bytes from a program on one computer to another program on another computer.
Exemple of server's code, receiving and sending basic message. It corresponds to the client used in the first exemple of vpClient class' documentation.
Exemple of server's code, receiving a vpImage on request form. It correspond to the client used in the second exemple of vpClient class' documentation.
Definition at line 163 of file vpServer.h.
vpServer::vpServer | ( | ) |
Construct a server on the machine launching it.
Definition at line 48 of file vpServer.cpp.
References vpNetwork::emitter, and vpERROR_TRACE.
|
explicit |
Construct a server on the machine launching it, with a specified port.
port_serv | : server's port. |
Definition at line 73 of file vpServer.cpp.
References vpNetwork::emitter, and vpERROR_TRACE.
vpServer::vpServer | ( | const std::string & | adress_serv, |
const int & | port_serv | ||
) |
Construct a server on the machine at a given adress, with a specified port.
adress_serv | : server's adress. |
port_serv | : server's port. |
Definition at line 99 of file vpServer.cpp.
References vpNetwork::emitter, and vpERROR_TRACE.
|
virtual |
Shutdown the server.
Definition at line 124 of file vpServer.cpp.
References vpNetwork::emitter, and vpNetwork::receptor_list.
|
inherited |
Add a decoding request to the emitter. This request will be used to decode the received messages. Each request must have a different id.
req | : Request to add. |
Definition at line 80 of file vpNetwork.cpp.
References vpRequest::getId(), and vpNetwork::request_list.
bool vpServer::checkForConnections | ( | ) |
Check if a client has connected or deconnected the server
Definition at line 200 of file vpServer.cpp.
References vpNetwork::emitter, vpNetwork::readFileDescriptor, vpNetwork::receptor_list, vpNetwork::socketMax, start(), vpNetwork::tv, vpNetwork::tv_sec, vpNetwork::tv_usec, and vpERROR_TRACE.
|
inline |
Get the maximum number of clients that can be connected to the server.
Definition at line 199 of file vpServer.h.
|
inlineinherited |
Get the maximum size that the emitter can receive (in request mode).
Definition at line 187 of file vpNetwork.h.
|
inline |
Get the number of clients connected to the server.
Definition at line 206 of file vpServer.h.
References vpNetwork::print().
|
inherited |
Get the receptor index from its name. The name can be either the IP, or its name on the network.
name | : Name of the receptor. |
Definition at line 135 of file vpNetwork.cpp.
References vpNetwork::receptor_list, and vpERROR_TRACE.
|
inlineinherited |
Get the Id of the request at the index ind.
ind | : Index of the request. |
Definition at line 173 of file vpNetwork.h.
|
inline |
Check if the server is started.
Definition at line 190 of file vpServer.h.
|
inherited |
Print the receptors.
id | : Message to display before the receptor's index. |
Definition at line 120 of file vpNetwork.cpp.
References vpNetwork::receptor_list.
Referenced by getNumberOfClients(), vpClient::getNumberOfServers(), vpClient::print(), and print().
void vpServer::print | ( | ) |
Print the connected clients.
Definition at line 286 of file vpServer.cpp.
References vpNetwork::print().
|
inherited |
Receives a object. The size of the received object is suppose to be the size of the type of the object. Note that a received message can correspond to a deconnection signal.
object | : Received object. |
sizeOfObject | : Size of the received object. |
Definition at line 277 of file vpNetwork.h.
References vpERROR_TRACE, and vpTRACE.
|
inherited |
Receives and decode requests untils there is requests to receive.
Definition at line 372 of file vpNetwork.cpp.
References vpNetwork::receiveRequest(), and vpNetwork::request_list.
|
inherited |
Receives and decode requests, from a specific emitter, untils there is request to receive.
receptorEmitting | : Index of the receptor emitting the message |
Definition at line 399 of file vpNetwork.cpp.
References vpNetwork::receiveRequestFrom(), and vpNetwork::request_list.
|
inherited |
Receives a message once (in the limit of the Maximum message size value). This message can represent an entire request or not. Several calls to this function might be necessary to get the entire request. If it represents an entire request, it decodes the request.
Definition at line 429 of file vpNetwork.cpp.
References vpNetwork::receiveRequestOnce(), and vpNetwork::request_list.
|
inherited |
Receives a message once (in the limit of the Maximum message size value), from a specific emitter. This message can represent an entire request or not. Several calls to this function might be necessary to get the entire request. If it represents an entire request, it decodes the request.
receptorEmitting | : Index of the receptor emitting the message. |
Definition at line 459 of file vpNetwork.cpp.
References vpNetwork::beginning, vpNetwork::currentMessageReceived, vpNetwork::end, vpNetwork::max_size_message, vpNetwork::param_sep, vpNetwork::readFileDescriptor, vpNetwork::receiveRequestOnceFrom(), vpNetwork::receptor_list, vpNetwork::request_list, vpNetwork::separator, vpNetwork::socketMax, vpNetwork::tv, vpNetwork::tv_sec, vpNetwork::tv_usec, vpNetwork::verboseMode, vpERROR_TRACE, and vpTRACE.
|
inherited |
Receives a object from a receptor, by specifying its size or not. Note that a received message can correspond to a deconnection signal.
object | : Received object. |
receptorEmitting | : Index of the receptor emitting the message. |
sizeOfObject | : Size of the received object. |
Definition at line 359 of file vpNetwork.h.
References vpERROR_TRACE, and vpTRACE.
|
inherited |
Receive requests untils there is requests to receive.
Definition at line 278 of file vpNetwork.cpp.
Referenced by vpNetwork::receiveAndDecodeRequest().
|
inherited |
Receives requests, from a specific emitter, untils there is request to receive.
receptorEmitting | : Index of the receptor emitting the message |
Definition at line 301 of file vpNetwork.cpp.
Referenced by vpNetwork::receiveAndDecodeRequestFrom().
|
inherited |
Receives a message once (in the limit of the Maximum message size value). This message can represent an entire request or not. Several calls to this function might be necessary to get the entire request.
Definition at line 325 of file vpNetwork.cpp.
Referenced by vpNetwork::receiveAndDecodeRequestOnce().
|
inherited |
Receives a message once (in the limit of the Maximum message size value), from a specific emitter. This message can represent an entire request or not. Several calls to this function might be necessary to get the entire request.
receptorEmitting | : Index of the receptor emitting the message. |
Definition at line 352 of file vpNetwork.cpp.
Referenced by vpNetwork::receiveAndDecodeRequestOnceFrom().
|
inherited |
Delete a decoding request from the emitter.
id | : Id of the request to delete. |
Definition at line 105 of file vpNetwork.cpp.
References vpNetwork::request_list.
|
inherited |
|
inherited |
Send an object. The size of the received object is suppose to be the size of its type. Note that sending object containing pointers, virtual methods, etc, won't probably work.
object | : Received object. |
sizeOfObject | : Size of the object |
Definition at line 431 of file vpNetwork.h.
References vpTRACE.
|
inherited |
Send and encode a request to the first receptor in the list.
req | : Request to send. |
Definition at line 238 of file vpNetwork.cpp.
References vpRequest::encode(), and vpNetwork::sendRequest().
|
inherited |
Send and encode a request to a specific receptor.
req | : Request to send. |
dest | : Index of the receptor receiving the request. |
Definition at line 258 of file vpNetwork.cpp.
References vpRequest::encode(), and vpNetwork::sendRequestTo().
|
inherited |
Send a request to the first receptor in the list.
req | : Request to send. |
Definition at line 170 of file vpNetwork.cpp.
References vpNetwork::sendRequestTo().
Referenced by vpNetwork::sendAndEncodeRequest().
|
inherited |
Send a request to a specific receptor.
req | : Request to send. |
dest | : Index of the receptor receiving the request. |
Definition at line 186 of file vpNetwork.cpp.
References vpNetwork::beginning, vpNetwork::end, vpRequest::getId(), vpNetwork::param_sep, vpNetwork::receptor_list, vpNetwork::separator, vpRequest::size(), vpNetwork::verboseMode, and vpTRACE.
Referenced by vpNetwork::sendAndEncodeRequestTo(), and vpNetwork::sendRequest().
|
inherited |
Send an object. The size has to be specified.
object | : Object to send. |
dest | : Index of the receptor that you are sending the object. |
sizeOfObject | : Size of the object. |
Definition at line 475 of file vpNetwork.h.
References vpTRACE.
|
inline |
Set the maximum number of clients that can be connected to the server.
l | : Maximum number of clients. |
Definition at line 219 of file vpServer.h.
|
inlineinherited |
Change the maximum size that the emitter can receive (in request mode).
s | : new maximum size value. |
Definition at line 223 of file vpNetwork.h.
|
inlineinherited |
Change the time the emitter spend to check if he receives a message from a receptor. Initially this value is set to 10usec.
sec | : new value in second. |
Definition at line 233 of file vpNetwork.h.
|
inlineinherited |
Change the time the emitter spend to check if he receives a message from a receptor. Initially this value is set to 10usec.
usec | : new value in micro second. |
Definition at line 243 of file vpNetwork.h.
|
inlineinherited |
Set the verbose mode.
mode | : Change the verbose mode. True to turn on, False to turn off. |
Definition at line 250 of file vpNetwork.h.
bool vpServer::start | ( | ) |
Enable the server to wait for clients (on the limit of the maximum limit).
Definition at line 145 of file vpServer.cpp.
References vpNetwork::emitter, and vpERROR_TRACE.
Referenced by checkForConnections().
|
protectedinherited |
Definition at line 137 of file vpNetwork.h.
Referenced by vpNetwork::receiveAndDecodeRequestOnceFrom(), and vpNetwork::sendRequestTo().
|
protectedinherited |
Definition at line 141 of file vpNetwork.h.
Referenced by vpNetwork::receiveAndDecodeRequestOnceFrom().
|
protectedinherited |
Definition at line 123 of file vpNetwork.h.
Referenced by checkForConnections(), start(), vpServer(), and ~vpServer().
|
protectedinherited |
Definition at line 138 of file vpNetwork.h.
Referenced by vpNetwork::receiveAndDecodeRequestOnceFrom(), and vpNetwork::sendRequestTo().
|
protectedinherited |
Definition at line 135 of file vpNetwork.h.
Referenced by vpNetwork::receiveAndDecodeRequestOnceFrom().
|
protectedinherited |
Definition at line 139 of file vpNetwork.h.
Referenced by vpNetwork::receiveAndDecodeRequestOnceFrom(), and vpNetwork::sendRequestTo().
|
protectedinherited |
Definition at line 125 of file vpNetwork.h.
Referenced by checkForConnections(), and vpNetwork::receiveAndDecodeRequestOnceFrom().
|
protectedinherited |
Definition at line 124 of file vpNetwork.h.
Referenced by checkForConnections(), vpClient::deconnect(), vpNetwork::getReceptorIndex(), vpNetwork::print(), vpClient::print(), vpNetwork::receiveAndDecodeRequestOnceFrom(), vpNetwork::sendRequestTo(), vpClient::stop(), and ~vpServer().
|
protectedinherited |
|
protectedinherited |
Definition at line 136 of file vpNetwork.h.
Referenced by vpNetwork::receiveAndDecodeRequestOnceFrom(), and vpNetwork::sendRequestTo().
|
protectedinherited |
Definition at line 127 of file vpNetwork.h.
Referenced by checkForConnections(), and vpNetwork::receiveAndDecodeRequestOnceFrom().
|
protectedinherited |
Definition at line 143 of file vpNetwork.h.
Referenced by checkForConnections(), vpNetwork::receiveAndDecodeRequestOnceFrom(), and vpNetwork::vpNetwork().
|
protectedinherited |
Definition at line 144 of file vpNetwork.h.
Referenced by checkForConnections(), vpNetwork::receiveAndDecodeRequestOnceFrom(), and vpNetwork::vpNetwork().
|
protectedinherited |
Definition at line 145 of file vpNetwork.h.
Referenced by checkForConnections(), vpNetwork::receiveAndDecodeRequestOnceFrom(), and vpNetwork::vpNetwork().
|
protectedinherited |
Definition at line 147 of file vpNetwork.h.
Referenced by vpNetwork::receiveAndDecodeRequestOnceFrom(), and vpNetwork::sendRequestTo().