8#ifndef FACEBOOK_NETWORK_CONNECTION_ORIENTED_CLIENT_H
9#define FACEBOOK_NETWORK_CONNECTION_ORIENTED_CLIENT_H
59 virtual bool connect(
const unsigned int timeout = 1000u);
137 virtual size_t onSend(
const void* data,
const size_t size);
144 virtual void onReceived(
const void* data,
const size_t size);
166 ocean_assert(strlen(message.c_str()) == message.length() && message.c_str()[message.length()] ==
'\0');
167 return send(message.c_str(), message.length() + 1);
This class implements a container for callback functions.
Definition Callback.h:3454
This class wraps an address number with 32 bits.
Definition Address4.h:26
Client()
Creates a new client.
virtual SocketResult send(const void *data, const size_t size)
Sends data via the established connection.
Address4 receiverAddress() const
Returns the (remote) receiver address.
Definition ConnectionOrientedClient.h:170
bool isConnected_
Determines whether a connection is established.
Definition ConnectionOrientedClient.h:161
Callback< void > DisconnectCallback
Definition of a disconnection callback function.
Definition ConnectionOrientedClient.h:41
~ConnectionOrientedClient() override
Destructs a connection oriented client.
Port receiverPort_
Receiver port.
Definition ConnectionOrientedClient.h:152
ConnectionOrientedClient()
Creates a new connection oriented client.
Port receiverPort() const
Returns the (remote) receiver port.
Definition ConnectionOrientedClient.h:176
bool onScheduler() override
The scheduler event function.
virtual bool isConnected() const
Returns whether this client is connected.
Callback< void, const void *, const size_t > ReceiveCallback
Definition of a data receive callback function.
Definition ConnectionOrientedClient.h:36
virtual bool disconnect()
Disconnects the client.
virtual void onReceived(const void *data, const size_t size)
Internal event function for received data.
Address4 receiverAddress_
Receiver address.
Definition ConnectionOrientedClient.h:149
virtual bool connect(const unsigned int timeout=1000u)
Reconnects the client by the usage of the most recent address and port.
DisconnectCallback disconnectCallback_
Disconnect callback function.
Definition ConnectionOrientedClient.h:158
ReceiveCallback receiveCallback_
Receive callback function.
Definition ConnectionOrientedClient.h:155
void setDisconnectCallback(const DisconnectCallback &callback)
Sets the disconnect callback function.
Definition ConnectionOrientedClient.h:188
void setReceiveCallback(const ReceiveCallback &callback)
Sets the receive callback function.
Definition ConnectionOrientedClient.h:182
virtual size_t onSend(const void *data, const size_t size)
Internal event function to send data.
virtual bool connect(const Address4 &address, const Port &port, const unsigned int timeout=1000u)
Connects to a connection-oriented server.
This class wraps a port number with 16 bits.
Definition Port.h:26
Address4 address() const
Returns the own address of this socket.
SocketResult
Definition of individual result values.
Definition Socket.h:62
Port port() const
Returns the own port of this socket.
Lock lock_
Socket lock.
Definition Socket.h:187
This class implements a scoped lock object for recursive lock objects.
Definition Lock.h:147
Namespace of the Network library.
Definition Address4.h:18
The namespace covering the entire Ocean framework.
Definition Accessor.h:15