![]() |
Visual Servoing Platform version 3.7.0
|
#include <vpNetwork.h>
Public Member Functions | |
| vpNetwork () | |
| vpNetwork (const vpNetwork &network) | |
| virtual | ~vpNetwork () |
| vpNetwork & | operator= (const vpNetwork &network) |
| 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 | 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) |
| template<typename T> | |
| int | send (T *object, const unsigned int &sizeOfObject) |
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) network.
TCP provides reliable, ordered delivery of a stream of bytes from a program on one computer to another program on another computer.
Definition at line 105 of file vpNetwork.h.
| BEGIN_VISP_NAMESPACE vpNetwork::vpNetwork | ( | ) |
Definition at line 50 of file vpNetwork.cpp.
References beginning, currentMessageReceived, emitter, end, max_size_message, param_sep, readFileDescriptor, receptor_list, request_list, separator, socketMax, tv, tv_sec, tv_usec, and verboseMode.
Referenced by operator=(), vpClient::vpClient(), vpClient::vpClient(), vpNetwork(), and vpServer::vpServer().
| vpNetwork::vpNetwork | ( | const vpNetwork & | network | ) |
Definition at line 71 of file vpNetwork.cpp.
References vpNetwork().
|
virtual |
Definition at line 105 of file vpNetwork.cpp.
| void vpNetwork::addDecodingRequest | ( | vpRequest * | req | ) |
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 123 of file vpNetwork.cpp.
References vpRequest::getId(), and request_list.
|
inline |
Get the maximum size that the emitter can receive (in request mode).
Definition at line 214 of file vpNetwork.h.
References max_size_message.
| int vpNetwork::getReceptorIndex | ( | const char * | name | ) |
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 178 of file vpNetwork.cpp.
References receptor_list, and vpERROR_TRACE.
|
inline |
Get the Id of the request at the index ind.
| ind | : Index of the request. |
Definition at line 199 of file vpNetwork.h.
References request_list.
Definition at line 76 of file vpNetwork.cpp.
References beginning, currentMessageReceived, emitter, end, max_size_message, param_sep, readFileDescriptor, receptor_list, request_list, separator, socketMax, tv, tv_sec, tv_usec, verboseMode, and vpNetwork().
| void vpNetwork::print | ( | const char * | id = "" | ) |
Print the receptors.
| id | : Message to display before the receptor's index. |
Definition at line 163 of file vpNetwork.cpp.
References receptor_list.
Referenced by vpClient::print(), and vpServer::print().
| int vpNetwork::receive | ( | T * | object, |
| const unsigned int & | sizeOfObject = sizeof(T) ) |
Receives a object. The size of the object received is assumed to correspond to the size of the object type. Note that a message received may correspond to a disconnection signal.
| object | : Received object. |
| sizeOfObject | : Size of the received object. |
Definition at line 304 of file vpNetwork.h.
References readFileDescriptor, receptor_list, socketMax, tv, tv_sec, tv_usec, verboseMode, vpERROR_TRACE, and vpTRACE.
| std::vector< int > vpNetwork::receiveAndDecodeRequest | ( | ) |
Receives and decode requests until there is requests to receive.
Definition at line 415 of file vpNetwork.cpp.
References receiveRequest(), and request_list.
| std::vector< int > vpNetwork::receiveAndDecodeRequestFrom | ( | const unsigned int & | receptorEmitting | ) |
Receives and decode requests, from a specific emitter, until there is request to receive.
| receptorEmitting | : Index of the receptor emitting the message |
Definition at line 442 of file vpNetwork.cpp.
References receiveRequestFrom(), and request_list.
| int vpNetwork::receiveAndDecodeRequestOnce | ( | ) |
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 472 of file vpNetwork.cpp.
References receiveRequestOnce(), and request_list.
| int vpNetwork::receiveAndDecodeRequestOnceFrom | ( | const unsigned int & | receptorEmitting | ) |
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 502 of file vpNetwork.cpp.
References receiveRequestOnceFrom(), and request_list.
| int vpNetwork::receiveFrom | ( | T * | object, |
| const unsigned int & | receptorEmitting, | ||
| const unsigned int & | sizeOfObject = sizeof(T) ) |
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 388 of file vpNetwork.h.
References readFileDescriptor, receptor_list, socketMax, tv, tv_sec, tv_usec, verboseMode, vpERROR_TRACE, and vpTRACE.
| std::vector< int > vpNetwork::receiveRequest | ( | ) |
Receive requests until there is requests to receive.
Definition at line 321 of file vpNetwork.cpp.
Referenced by receiveAndDecodeRequest().
| std::vector< int > vpNetwork::receiveRequestFrom | ( | const unsigned int & | receptorEmitting | ) |
Receives requests, from a specific emitter, until there is request to receive.
| receptorEmitting | : Index of the receptor emitting the message |
Definition at line 344 of file vpNetwork.cpp.
Referenced by receiveAndDecodeRequestFrom().
| int vpNetwork::receiveRequestOnce | ( | ) |
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 368 of file vpNetwork.cpp.
Referenced by receiveAndDecodeRequestOnce().
| int vpNetwork::receiveRequestOnceFrom | ( | const unsigned int & | receptorEmitting | ) |
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 395 of file vpNetwork.cpp.
Referenced by receiveAndDecodeRequestOnceFrom().
| void vpNetwork::removeDecodingRequest | ( | const char * | id | ) |
Delete a decoding request from the emitter.
| id | : Id of the request to delete. |
Definition at line 148 of file vpNetwork.cpp.
References request_list.
| int vpNetwork::send | ( | T * | object, |
| const int unsigned & | sizeOfObject = sizeof(T) ) |
References sendAndEncodeRequest(), sendAndEncodeRequestTo(), sendRequest(), sendRequestTo(), and sendTo().
| int vpNetwork::send | ( | T * | object, |
| const unsigned int & | sizeOfObject ) |
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 462 of file vpNetwork.h.
References receptor_list, verboseMode, and vpTRACE.
| int vpNetwork::sendAndEncodeRequest | ( | vpRequest & | req | ) |
Send and encode a request to the first receptor in the list.
| req | : Request to send. |
Definition at line 281 of file vpNetwork.cpp.
References vpRequest::encode(), and sendRequest().
Referenced by send().
| int vpNetwork::sendAndEncodeRequestTo | ( | vpRequest & | req, |
| const unsigned int & | dest ) |
Send and encode a request to a specific receptor.
| req | : Request to send. |
| dest | : Index of the receptor receiving the request. |
Definition at line 301 of file vpNetwork.cpp.
References vpRequest::encode(), and sendRequestTo().
Referenced by send().
| int vpNetwork::sendRequest | ( | vpRequest & | req | ) |
Send a request to the first receptor in the list.
| req | : Request to send. |
Definition at line 213 of file vpNetwork.cpp.
References sendRequestTo().
Referenced by send(), and sendAndEncodeRequest().
| int vpNetwork::sendRequestTo | ( | vpRequest & | req, |
| const unsigned int & | dest ) |
Send a request to a specific receptor.
| req | : Request to send. |
| dest | : Index of the receptor receiving the request. |
Definition at line 229 of file vpNetwork.cpp.
References beginning, end, vpRequest::getId(), param_sep, receptor_list, separator, vpRequest::size(), verboseMode, and vpTRACE.
Referenced by send(), sendAndEncodeRequestTo(), and sendRequest().
| int vpNetwork::sendTo | ( | T * | object, |
| const unsigned int & | dest, | ||
| const unsigned int & | sizeOfObject = sizeof(T) ) |
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 506 of file vpNetwork.h.
References receptor_list, verboseMode, and vpTRACE.
Referenced by send().
|
inline |
Change the maximum size that the emitter can receive (in request mode).
| s | : new maximum size value. |
Definition at line 250 of file vpNetwork.h.
References max_size_message.
|
inline |
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 260 of file vpNetwork.h.
References tv_sec.
|
inline |
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 270 of file vpNetwork.h.
References tv_usec.
|
inline |
Set the verbose mode.
| mode | : Change the verbose mode. True to turn on, False to turn off. |
Definition at line 277 of file vpNetwork.h.
References verboseMode.
|
protected |
Definition at line 160 of file vpNetwork.h.
Referenced by operator=(), sendRequestTo(), and vpNetwork().
|
protected |
Definition at line 164 of file vpNetwork.h.
Referenced by operator=(), and vpNetwork().
|
protected |
Definition at line 146 of file vpNetwork.h.
Referenced by vpServer::checkForConnections(), operator=(), vpServer::start(), vpNetwork(), vpServer::vpServer(), vpServer::vpServer(), vpServer::vpServer(), and vpServer::~vpServer().
|
protected |
Definition at line 161 of file vpNetwork.h.
Referenced by operator=(), sendRequestTo(), and vpNetwork().
|
protected |
Definition at line 158 of file vpNetwork.h.
Referenced by getMaxSizeReceivedMessage(), operator=(), setMaxSizeReceivedMessage(), and vpNetwork().
|
protected |
Definition at line 162 of file vpNetwork.h.
Referenced by operator=(), sendRequestTo(), and vpNetwork().
|
protected |
Definition at line 148 of file vpNetwork.h.
Referenced by vpServer::checkForConnections(), operator=(), receive(), receiveFrom(), and vpNetwork().
|
protected |
Definition at line 147 of file vpNetwork.h.
Referenced by vpServer::checkForConnections(), vpClient::deconnect(), vpServer::getNumberOfClients(), vpClient::getNumberOfServers(), getReceptorIndex(), operator=(), print(), receive(), receiveFrom(), send(), sendRequestTo(), sendTo(), vpClient::stop(), vpNetwork(), and vpServer::~vpServer().
|
protected |
Definition at line 156 of file vpNetwork.h.
Referenced by addDecodingRequest(), getRequestIdFromIndex(), operator=(), receiveAndDecodeRequest(), receiveAndDecodeRequestFrom(), receiveAndDecodeRequestOnce(), receiveAndDecodeRequestOnceFrom(), removeDecodingRequest(), and vpNetwork().
|
protected |
Definition at line 159 of file vpNetwork.h.
Referenced by operator=(), sendRequestTo(), and vpNetwork().
|
protected |
Definition at line 150 of file vpNetwork.h.
Referenced by vpServer::checkForConnections(), operator=(), receive(), receiveFrom(), and vpNetwork().
|
protected |
Definition at line 166 of file vpNetwork.h.
Referenced by vpServer::checkForConnections(), operator=(), receive(), receiveFrom(), and vpNetwork().
|
protected |
Definition at line 167 of file vpNetwork.h.
Referenced by vpServer::checkForConnections(), operator=(), receive(), receiveFrom(), setTimeoutSec(), and vpNetwork().
|
protected |
Definition at line 168 of file vpNetwork.h.
Referenced by vpServer::checkForConnections(), operator=(), receive(), receiveFrom(), setTimeoutUSec(), and vpNetwork().
|
protected |
Definition at line 170 of file vpNetwork.h.
Referenced by operator=(), receive(), receiveFrom(), send(), sendRequestTo(), sendTo(), setVerbose(), and vpNetwork().