Ocean
|
This class is the base class for all connection oriented clients. More...
Public Types | |
typedef Callback< void, const void *, const size_t > | ReceiveCallback |
Definition of a data receive callback function. More... | |
typedef Callback< void > | DisconnectCallback |
Definition of a disconnection callback function. More... | |
Public Types inherited from Ocean::Network::Socket | |
enum | SocketResult { SR_SUCCEEDED = 0 , SR_FAILED , SR_BUSY , SR_NOT_CONNECTED } |
Definition of individual result values. More... | |
typedef SOCKET | SocketId |
Definition of a socket id. More... | |
typedef int | SocketId |
Definition of a socket id. More... | |
typedef std::vector< uint8_t > | Buffer |
Definition of a vector holding 8 bit values. More... | |
Public Member Functions | |
virtual bool | connect (const Address4 &address, const Port &port, const unsigned int timeout=1000u) |
Connects to a connection-oriented server. More... | |
virtual bool | connect (const unsigned int timeout=1000u) |
Reconnects the client by the usage of the most recent address and port. More... | |
virtual bool | disconnect () |
Disconnects the client. More... | |
virtual bool | isConnected () const |
Returns whether this client is connected. More... | |
virtual SocketResult | send (const void *data, const size_t size) |
Sends data via the established connection. More... | |
SocketResult | send (const std::string &message) |
Sets a message via the established connection. More... | |
Address4 | receiverAddress () const |
Returns the (remote) receiver address. More... | |
Port | receiverPort () const |
Returns the (remote) receiver port. More... | |
void | setReceiveCallback (const ReceiveCallback &callback) |
Sets the receive callback function. More... | |
void | setDisconnectCallback (const DisconnectCallback &callback) |
Sets the disconnect callback function. More... | |
Public Member Functions inherited from Ocean::Network::Socket | |
virtual | ~Socket () |
Destructs a socket object. More... | |
SocketId | id () const |
Returns the socket id. More... | |
Address4 | address () const |
Returns the own address of this socket. More... | |
Port | port () const |
Returns the own port of this socket. More... | |
virtual bool | setAddress (const Address4 &address) |
Sets the own address of this socket. More... | |
virtual bool | setPort (const Port &port) |
Sets the own port of this socket. More... | |
operator bool () const | |
Returns whether this socket is valid. More... | |
Protected Member Functions | |
ConnectionOrientedClient () | |
Creates a new connection oriented client. More... | |
~ConnectionOrientedClient () override | |
Destructs a connection oriented client. More... | |
bool | onScheduler () override |
The scheduler event function. More... | |
virtual size_t | onSend (const void *data, const size_t size) |
Internal event function to send data. More... | |
virtual void | onReceived (const void *data, const size_t size) |
Internal event function for received data. More... | |
Protected Member Functions inherited from Ocean::Network::Client | |
Client () | |
Creates a new client. More... | |
~Client () override | |
Destructs a client. More... | |
Protected Member Functions inherited from Ocean::Network::Socket | |
Socket () | |
Creates a new socket object. More... | |
Socket (const Socket &object)=delete | |
Disabled copy constructor. More... | |
bool | setBlockingMode (const bool blocking) |
Sets the blocking mode of this socket. More... | |
size_t | maximalMessageSize (const size_t defaultSize=65536) |
Returns the maximal message size in bytes. More... | |
bool | releaseSocket () |
Releases the socket. More... | |
Socket & | operator= (const Socket &object)=delete |
Disabled copy operator. More... | |
Protected Attributes | |
Address4 | receiverAddress_ |
Receiver address. More... | |
Port | receiverPort_ |
Receiver port. More... | |
ReceiveCallback | receiveCallback_ |
Receive callback function. More... | |
DisconnectCallback | disconnectCallback_ |
Disconnect callback function. More... | |
bool | isConnected_ = false |
Determines whether a connection is established. More... | |
Protected Attributes inherited from Ocean::Network::Client | |
Buffer | socketBuffer_ |
The socket buffer of this client. More... | |
Protected Attributes inherited from Ocean::Network::Socket | |
SocketId | socketId_ = invalidSocketId() |
Socket id. More... | |
Lock | lock_ |
Socket lock. More... | |
NetworkResource | networkResource_ |
The network resource object. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from Ocean::Network::Socket | |
static constexpr SocketId | invalidSocketId () |
Returns an invalid socket id. More... | |
static bool | setBlockingMode (const SocketId socketId, const bool blocking) |
Sets the blocking mode of a socket. More... | |
This class is the base class for all connection oriented clients.
Definition of a disconnection callback function.
typedef Callback<void, const void*, const size_t> Ocean::Network::ConnectionOrientedClient::ReceiveCallback |
Definition of a data receive callback function.
The first parameter provides the received data, which must be copied The second parameter provides the size of the received data, in bytes
|
protected |
Creates a new connection oriented client.
|
overrideprotected |
Destructs a connection oriented client.
|
virtual |
Connects to a connection-oriented server.
address | Remote address of the server to connect |
port | Remote port of the server to connect |
timeout | The timeout in milliseconds, with range [0, infinity) |
Reimplemented in Ocean::Network::TCPClient.
|
virtual |
Reconnects the client by the usage of the most recent address and port.
timeout | The timeout in milliseconds, with range [0, infinity) |
Reimplemented in Ocean::Network::TCPClient.
|
virtual |
Disconnects the client.
Reimplemented in Ocean::Network::TCPClient.
|
virtual |
Returns whether this client is connected.
|
protectedvirtual |
Internal event function for received data.
data | The data that has been received, must be valid |
size | The size of the data in bytes, with range [1, infinity) |
Reimplemented in Ocean::Network::PackagedTCPClient.
|
overrideprotectedvirtual |
|
protectedvirtual |
Internal event function to send data.
data | The data to send, must be valid |
size | The size of the data in bytes, with range [1, infinity) |
Reimplemented in Ocean::Network::PackagedTCPClient.
|
inline |
Returns the (remote) receiver address.
|
inline |
Returns the (remote) receiver port.
|
inline |
Sets a message via the established connection.
message | The message to send, must be valid |
|
virtual |
Sends data via the established connection.
If the resource is busy SR_FAILED will be returned and the caller needs to send the data later
data | The data to send, can be nullptr if 'size == 0' |
size | The size of the data to send, in bytes, with range [0, infinity) |
|
inline |
Sets the disconnect callback function.
callback | The callback function to set |
|
inline |
Sets the receive callback function.
callback | The callback function to set |
|
protected |
Disconnect callback function.
|
protected |
Determines whether a connection is established.
|
protected |
Receive callback function.
|
protected |
Receiver address.
|
protected |
Receiver port.