![]() |
Visual Servoing Platform
version 3.3.0
|
#include <vpClient.h>
Public Member Functions | |
vpClient () | |
virtual | ~vpClient () |
bool | connectToHostname (const std::string &hostname, const unsigned int &port_serv) |
bool | connectToIP (const std::string &ip, const unsigned int &port_serv) |
void | deconnect (const unsigned int &index=0) |
unsigned int | getNumberOfAttempts () |
unsigned int | getNumberOfServers () |
void | print () |
void | setNumberOfAttempts (const unsigned int &nb) |
void | stop () |
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) client.
TCP provides reliable, ordered delivery of a stream of bytes from a program on one computer to another program on another computer.
Exemple of client's code, receiving and sending basic message It corresponds to the client used in the first exemple of vpServer class' documentation:
Exemple of client's code, sending a vpImage on request form. It correspond to the server used in the second exemple of vpServer class' documentation.
Definition at line 166 of file vpClient.h.
vpClient::vpClient | ( | ) |
Definition at line 43 of file vpClient.cpp.
|
virtual |
Disconnect the client from all the servers, and close the sockets.
Definition at line 48 of file vpClient.cpp.
|
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 82 of file vpNetwork.cpp.
bool vpClient::connectToHostname | ( | const std::string & | hostname, |
const unsigned int & | port_serv | ||
) |
Connect to the server represented by the given hostname, and at a given port.
hostname | : Hostname of the server. |
port_serv | : Port used for the connection. |
Definition at line 61 of file vpClient.cpp.
bool vpClient::connectToIP | ( | const std::string & | ip, |
const unsigned int & | port_serv | ||
) |
Connect to the server represented by the given ip, and at a given port.
ip | : IP of the server. |
port_serv | : Port used for the connection. |
Definition at line 108 of file vpClient.cpp.
void vpClient::deconnect | ( | const unsigned int & | index = 0 | ) |
Deconnect from the server at a specific index.
index | : Index of the server. |
Definition at line 136 of file vpClient.cpp.
|
inlineinherited |
Get the maximum size that the emitter can receive (in request mode).
Definition at line 192 of file vpNetwork.h.
|
inline |
Get the actual number of attempts to connect to the server.
Definition at line 196 of file vpClient.h.
|
inline |
Get the number of server that the client is connected on.
Definition at line 203 of file vpClient.h.
|
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 137 of file vpNetwork.cpp.
|
inlineinherited |
Get the Id of the request at the index ind.
ind | : Index of the request. |
Definition at line 178 of file vpNetwork.h.
void vpClient::print | ( | ) |
Print the servers.
Definition at line 167 of file vpClient.cpp.
|
inherited |
Print the receptors.
id | : Message to display before the receptor's index. |
Definition at line 122 of file vpNetwork.cpp.
|
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 282 of file vpNetwork.h.
|
inherited |
Receives and decode requests untils there is requests to receive.
Definition at line 374 of file vpNetwork.cpp.
|
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 401 of file vpNetwork.cpp.
|
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 431 of file vpNetwork.cpp.
|
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 461 of file vpNetwork.cpp.
|
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 364 of file vpNetwork.h.
References vpNetwork::readFileDescriptor, vpNetwork::receptor_list, vpNetwork::socketMax, vpNetwork::tv, vpNetwork::tv_sec, vpNetwork::tv_usec, vpNetwork::verboseMode, vpERROR_TRACE, and vpTRACE.
|
inherited |
Receive requests untils there is requests to receive.
Definition at line 280 of file vpNetwork.cpp.
|
inherited |
Receives requests, from a specific emitter, untils there is request to receive.
receptorEmitting | : Index of the receptor emitting the message |
Definition at line 303 of file vpNetwork.cpp.
|
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 327 of file vpNetwork.cpp.
|
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 354 of file vpNetwork.cpp.
|
inherited |
Delete a decoding request from the emitter.
id | : Id of the request to delete. |
Definition at line 107 of file vpNetwork.cpp.
|
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 436 of file vpNetwork.h.
|
inherited |
Send and encode a request to the first receptor in the list.
req | : Request to send. |
Definition at line 240 of file vpNetwork.cpp.
|
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 260 of file vpNetwork.cpp.
|
inherited |
Send a request to the first receptor in the list.
req | : Request to send. |
Definition at line 172 of file vpNetwork.cpp.
|
inherited |
Send a request to a specific receptor.
req | : Request to send. |
dest | : Index of the receptor receiving the request. |
Definition at line 188 of file vpNetwork.cpp.
|
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 480 of file vpNetwork.h.
|
inlineinherited |
Change the maximum size that the emitter can receive (in request mode).
s | : new maximum size value. |
Definition at line 228 of file vpNetwork.h.
|
inline |
Set the number of attempts to connect to the server.
nb | : Number of attempts. |
Definition at line 214 of file vpClient.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 238 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 248 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 255 of file vpNetwork.h.
void vpClient::stop | ( | ) |
Stops the server and close the sockets.
Definition at line 151 of file vpClient.cpp.
|
protectedinherited |
Definition at line 142 of file vpNetwork.h.
|
protectedinherited |
Definition at line 146 of file vpNetwork.h.
|
protectedinherited |
Definition at line 128 of file vpNetwork.h.
|
protectedinherited |
Definition at line 143 of file vpNetwork.h.
|
protectedinherited |
Definition at line 140 of file vpNetwork.h.
|
protectedinherited |
Definition at line 144 of file vpNetwork.h.
|
protectedinherited |
Definition at line 130 of file vpNetwork.h.
Referenced by vpNetwork::receiveFrom().
|
protectedinherited |
Definition at line 129 of file vpNetwork.h.
Referenced by vpNetwork::receiveFrom().
|
protectedinherited |
Definition at line 138 of file vpNetwork.h.
|
protectedinherited |
Definition at line 141 of file vpNetwork.h.
|
protectedinherited |
Definition at line 132 of file vpNetwork.h.
Referenced by vpNetwork::receiveFrom().
|
protectedinherited |
Definition at line 148 of file vpNetwork.h.
Referenced by vpNetwork::receiveFrom(), and vpNetwork::vpNetwork().
|
protectedinherited |
Definition at line 149 of file vpNetwork.h.
Referenced by vpNetwork::receiveFrom(), and vpNetwork::vpNetwork().
|
protectedinherited |
Definition at line 150 of file vpNetwork.h.
Referenced by vpNetwork::receiveFrom(), and vpNetwork::vpNetwork().
|
protectedinherited |
Definition at line 152 of file vpNetwork.h.
Referenced by vpNetwork::receiveFrom().