|
Ocean
|
This class implements a TCP client. More...
#include <TCPClient.h>
Public Member Functions | |
| TCPClient () | |
| Creates a new TCP client. | |
| ~TCPClient () override | |
| Destructs a TCP client. | |
| bool | connect (const Address4 &address, const Port &port, const unsigned int timeout=1000u) override |
| Connects to a TCP server. | |
| bool | connect (const unsigned int timeout=1000u) override |
| Reconnects the client by the usage of the most recent address and port. | |
| bool | disconnect () override |
| Disconnects the client. | |
Public Member Functions inherited from Ocean::Network::ConnectionOrientedClient | |
| virtual bool | isConnected () const |
| Returns whether this client is connected. | |
| virtual SocketResult | send (const void *data, const size_t size) |
| Sends data via the established connection. | |
| SocketResult | send (const std::string &message) |
| Sets a message via the established connection. | |
| Address4 | receiverAddress () const |
| Returns the (remote) receiver address. | |
| Port | receiverPort () const |
| Returns the (remote) receiver port. | |
| void | setReceiveCallback (const ReceiveCallback &callback) |
| Sets the receive callback function. | |
| void | setDisconnectCallback (const DisconnectCallback &callback) |
| Sets the disconnect callback function. | |
Public Member Functions inherited from Ocean::Network::Socket | |
| virtual | ~Socket () |
| Destructs a socket object. | |
| SocketId | id () const |
| Returns the socket id. | |
| Address4 | address () const |
| Returns the own address of this socket. | |
| Port | port () const |
| Returns the own port of this socket. | |
| virtual bool | setAddress (const Address4 &address) |
| Sets the own address of this socket. | |
| virtual bool | setPort (const Port &port) |
| Sets the own port of this socket. | |
| operator bool () const | |
| Returns whether this socket is valid. | |
Protected Member Functions | |
| bool | buildSocket () |
| Build the TCP socket. | |
Protected Member Functions inherited from Ocean::Network::ConnectionOrientedClient | |
| ConnectionOrientedClient () | |
| Creates a new connection oriented client. | |
| ~ConnectionOrientedClient () override | |
| Destructs a connection oriented client. | |
| bool | onScheduler () override |
| The scheduler event function. | |
| virtual size_t | onSend (const void *data, const size_t size) |
| Internal event function to send data. | |
| virtual void | onReceived (const void *data, const size_t size) |
| Internal event function for received data. | |
Protected Member Functions inherited from Ocean::Network::Client | |
| Client () | |
| Creates a new client. | |
| ~Client () override | |
| Destructs a client. | |
Protected Member Functions inherited from Ocean::Network::Socket | |
| Socket () | |
| Creates a new socket object. | |
| Socket (const Socket &object)=delete | |
| Disabled copy constructor. | |
| bool | setBlockingMode (const bool blocking) |
| Sets the blocking mode of this socket. | |
| size_t | maximalMessageSize (const size_t defaultSize=65536) |
| Returns the maximal message size in bytes. | |
| bool | releaseSocket () |
| Releases the socket. | |
| Socket & | operator= (const Socket &object)=delete |
| Disabled copy operator. | |
Additional Inherited Members | |
Public Types inherited from Ocean::Network::ConnectionOrientedClient | |
| using | ReceiveCallback = Callback< void, const void *, const size_t > |
| Definition of a data receive callback function. | |
| using | DisconnectCallback = Callback< void > |
| Definition of a disconnection callback function. | |
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... | |
| using | SocketId = SOCKET |
| Definition of a socket id. | |
| using | SocketId = int |
| Definition of a socket id. | |
| using | Buffer = std::vector< uint8_t > |
| Definition of a vector holding 8 bit values. | |
Static Public Member Functions inherited from Ocean::Network::Socket | |
| static constexpr SocketId | invalidSocketId () |
| Returns an invalid socket id. | |
| static bool | setBlockingMode (const SocketId socketId, const bool blocking) |
| Sets the blocking mode of a socket. | |
Protected Attributes inherited from Ocean::Network::ConnectionOrientedClient | |
| Address4 | receiverAddress_ |
| Receiver address. | |
| Port | receiverPort_ |
| Receiver port. | |
| ReceiveCallback | receiveCallback_ |
| Receive callback function. | |
| DisconnectCallback | disconnectCallback_ |
| Disconnect callback function. | |
| bool | isConnected_ = false |
| Determines whether a connection is established. | |
Protected Attributes inherited from Ocean::Network::Client | |
| Buffer | socketBuffer_ |
| The socket buffer of this client. | |
Protected Attributes inherited from Ocean::Network::Socket | |
| SocketId | socketId_ = invalidSocketId() |
| Socket id. | |
| Lock | lock_ |
| Socket lock. | |
| NetworkResource | networkResource_ |
| The network resource object. | |
This class implements a TCP client.
A TCP client can send and receive data to (and from) one remove TCP client.
TCP is a stream-based network protocol which does not provide any message boundaries.
| Ocean::Network::TCPClient::TCPClient | ( | ) |
Creates a new TCP client.
|
override |
Destructs a TCP client.
|
protected |
Build the TCP socket.
|
overridevirtual |
Connects to a TCP server.
Reimplemented from Ocean::Network::ConnectionOrientedClient.
|
overridevirtual |
Reconnects the client by the usage of the most recent address and port.
Reimplemented from Ocean::Network::ConnectionOrientedClient.
|
overridevirtual |
Disconnects the client.
Reimplemented from Ocean::Network::ConnectionOrientedClient.