![]() |
An open-source, flexible 3D physical simulation framework
|
#include <Socket.h>
Public Member Functions | |
TCPConnection () | |
~TCPConnection () | |
SocketError | connectToTCPServer (const std::string &host, unsigned short port) |
Connects to a given server on the given port . More... | |
void | close () |
Closes the connection. More... | |
bool | isConnected () const |
Queries whether there is an established connection. More... | |
SocketError | sendAll (const std::string &data) |
Sends the entire string. More... | |
SocketError | sendAll (const char *data, size_t len) |
Sends the entire string. More... | |
size_t | send (const char *data, size_t len) |
Send the data buffer over the connection. More... | |
SocketError | recvAll (char *data, size_t len) |
Receives exactly len bytes and stores them in data. More... | |
size_t | recv (char *data, size_t max) |
Receive at most max bytes and store them in data This does not guarantee that actually max bytes are received. More... | |
SocketError | sendBinary (const void *data, size_t len) |
Convenience function to send len bytes of binary data. More... | |
SocketError | recvBinary (void *data, size_t len) |
Convenience function to receive len bytes of binary data. More... | |
void | setBlocking (bool blocking) |
Not Implemented Yet. More... | |
bool | isBlocking () const |
Not Implemented Yet. More... | |
void | setTimeout (double timeout) |
Not Implemented Yet. More... | |
double | getTimeout () const |
Not Implemented Yet. More... | |
SocketError | sendInt32 (int32_t val) |
Convenience function to send a 32-bit signed integer in a endian aware manner. More... | |
SocketError | recvInt32 (int32_t *val) |
Convenience function to receive a 32-bit signed integer in a endian aware manner. More... | |
SocketError | sendUInt32 (uint32_t val) |
Convenience function to send a 32-bit unsigned integer in a endian aware manner. More... | |
SocketError | recvUInt32 (uint32_t *val) |
Convenience function to receive a 32-bit unsigned integer in a endian aware manner. More... | |
SocketError | sendFloat (float val) |
Convenience function to send a single precision float in a endian aware manner. More... | |
SocketError | recvFloat (float *val) |
Convenience function to receive a single precision float in a endian aware manner. More... | |
SocketError | sendDouble (double val) |
Convenience function to send a double precision float in a endian aware manner. More... | |
SocketError | recvDouble (double *val) |
Convenience function to receive a double precision float in a endian aware manner. More... | |
Private Member Functions | |
TCPConnection (const TCPConnection &other) | |
TCPConnection & | operator= (const TCPConnection &other) |
Private Attributes | |
TCPBaseSocket * | s |
Friends | |
SocketError | TCPServer::acceptConnection (TCPConnection *c) const |
mars::utils::TCPConnection::TCPConnection | ( | ) |
Definition at line 184 of file Socket.cpp.
mars::utils::TCPConnection::~TCPConnection | ( | ) |
Definition at line 188 of file Socket.cpp.
|
private |
Definition at line 297 of file Socket.cpp.
void mars::utils::TCPConnection::close | ( | ) |
Closes the connection.
It is safe to call this even if there is no connection established.
Definition at line 208 of file Socket.cpp.
SocketError mars::utils::TCPConnection::connectToTCPServer | ( | const std::string & | host, |
unsigned short | port | ||
) |
Connects to a given server on the given port
.
Definition at line 195 of file Socket.cpp.
double mars::utils::TCPConnection::getTimeout | ( | ) | const |
Not Implemented Yet.
Definition at line 293 of file Socket.cpp.
bool mars::utils::TCPConnection::isBlocking | ( | ) | const |
Not Implemented Yet.
Definition at line 287 of file Socket.cpp.
bool mars::utils::TCPConnection::isConnected | ( | ) | const |
Queries whether there is an established connection.
Definition at line 211 of file Socket.cpp.
|
private |
Definition at line 301 of file Socket.cpp.
size_t mars::utils::TCPConnection::recv | ( | char * | data, |
size_t | max | ||
) |
Receive at most max bytes and store them in data This does not guarantee that actually max bytes are received.
data | A pointer to a buffer that can hold at least max bytes. |
max | The maximum of bytes to receive before returning. |
Definition at line 251 of file Socket.cpp.
SocketError mars::utils::TCPConnection::recvAll | ( | char * | data, |
size_t | len | ||
) |
Receives exactly len bytes and stores them in data.
Under the hood this repeatedly calls recv until len bytes are received.
data | A pointer to a buffer that can hold at least len bytes. |
len | The number of bytes to receive before returning. |
Definition at line 238 of file Socket.cpp.
SocketError mars::utils::TCPConnection::recvBinary | ( | void * | data, |
size_t | len | ||
) |
Convenience function to receive len bytes of binary data.
This will receive len bytes convert them from Network-Byte-Order to Host-Byte-Order and store them in the buffer pointed to by data.
Definition at line 271 of file Socket.cpp.
|
inline |
Convenience function to receive a double precision float in a endian aware manner.
|
inline |
Convenience function to receive a single precision float in a endian aware manner.
|
inline |
Convenience function to receive a 32-bit signed integer in a endian aware manner.
|
inline |
Convenience function to receive a 32-bit unsigned integer in a endian aware manner.
size_t mars::utils::TCPConnection::send | ( | const char * | data, |
size_t | len | ||
) |
Send the data
buffer over the connection.
This does not guarantee that the entire data
buffer is transferred.
data | The data buffer to be sent over the connection. |
len | The length of the data buffer. |
Definition at line 231 of file Socket.cpp.
SocketError mars::utils::TCPConnection::sendAll | ( | const std::string & | data | ) |
Sends the entire string.
Under the hood this repeatedly calls send until the entire string is transferred.
Definition at line 214 of file Socket.cpp.
SocketError mars::utils::TCPConnection::sendAll | ( | const char * | data, |
size_t | len | ||
) |
Sends the entire string.
Under the hood this repeatedly calls send until the entire string is transferred.
Definition at line 217 of file Socket.cpp.
SocketError mars::utils::TCPConnection::sendBinary | ( | const void * | data, |
size_t | len | ||
) |
Convenience function to send len bytes of binary data.
This will transmit the len bytes pointed to by data in Network-Byte-Order.
Definition at line 257 of file Socket.cpp.
|
inline |
Convenience function to send a double precision float in a endian aware manner.
|
inline |
Convenience function to send a single precision float in a endian aware manner.
|
inline |
Convenience function to send a 32-bit signed integer in a endian aware manner.
|
inline |
Convenience function to send a 32-bit unsigned integer in a endian aware manner.
void mars::utils::TCPConnection::setBlocking | ( | bool | blocking | ) |
Not Implemented Yet.
Definition at line 285 of file Socket.cpp.
void mars::utils::TCPConnection::setTimeout | ( | double | timeout | ) |
Not Implemented Yet.
Definition at line 290 of file Socket.cpp.
|
friend |
|
private |