Ocean
PackagedTCPClient.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef FACEBOOK_NETWORK_PACKAGED_TCP_CLIENT_H
9 #define FACEBOOK_NETWORK_PACKAGED_TCP_CLIENT_H
10 
11 #include "ocean/network/Network.h"
14 
15 namespace Ocean
16 {
17 
18 namespace Network
19 {
20 
21 /**
22  * This class implements a TCP client with internal package handling.
23  * @ingroup network
24  */
25 class OCEAN_NETWORK_EXPORT PackagedTCPClient :
26  virtual public TCPClient,
27  virtual protected PackagedSocket
28 {
29  public:
30 
31  /**
32  * Creates a new TCP client.
33  */
34  PackagedTCPClient() = default;
35 
36  /**
37  * Destructs a TCP client.
38  */
39  ~PackagedTCPClient() override = default;
40 
41  protected:
42 
43  /**
44  * Internal event function to send data.
45  * @see ConnectionOrientedClient::onSend().
46  */
47  size_t onSend(const void* data, const size_t size) override;
48 
49  /**
50  * Internal event function for received data.
51  * @see ConnectionOrientedClient::onReceived().
52  */
53  void onReceived(const void* data, const size_t size) override;
54 
55  protected:
56 
57  /// The queue holding all memory blocks recently received and not yet process.
59 
60  /// The memory block to be filled.
62 
63  /// The memory block for the package header.
65 };
66 
67 }
68 
69 }
70 
71 #endif // FACEBOOK_NETWORK_PACKAGED_TCP_CLIENT_H
This class implements a memory block.
Definition: PackagedSocket.h:38
This class is the base class for all packaged sockets.
Definition: PackagedSocket.h:31
std::queue< MemoryBlock > MemoryBlockQueue
Definition of a queue holding memory blocks.
Definition: PackagedSocket.h:133
This class implements a TCP client with internal package handling.
Definition: PackagedTCPClient.h:28
void onReceived(const void *data, const size_t size) override
Internal event function for received data.
size_t onSend(const void *data, const size_t size) override
Internal event function to send data.
MemoryBlock currentMemory_
The memory block to be filled.
Definition: PackagedTCPClient.h:61
~PackagedTCPClient() override=default
Destructs a TCP client.
MemoryBlockQueue memoryQueue_
The queue holding all memory blocks recently received and not yet process.
Definition: PackagedTCPClient.h:58
PackagedTCPClient()=default
Creates a new TCP client.
MemoryBlock currentPackageHeaderMemory_
The memory block for the package header.
Definition: PackagedTCPClient.h:64
This class implements a TCP client.
Definition: TCPClient.h:27
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15