Ocean
Loading...
Searching...
No Matches
TCPClient.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_TCP_CLIENT_H
9#define FACEBOOK_NETWORK_TCP_CLIENT_H
10
13
14namespace Ocean
15{
16
17namespace Network
18{
19
20/**
21 * This class implements a TCP client.
22 * A TCP client can send and receive data to (and from) one remove TCP client.<br>
23 * TCP is a stream-based network protocol which does not provide any message boundaries.<br>
24 * @ingroup network
25 */
26class OCEAN_NETWORK_EXPORT TCPClient : virtual public ConnectionOrientedClient
27{
28 public:
29
30 /**
31 * Creates a new TCP client.
32 */
34
35 /**
36 * Destructs a TCP client.
37 */
38 ~TCPClient() override;
39
40 /**
41 * Connects to a TCP server.
42 * @see ConnectionOrientedClient::connect().
43 */
44 bool connect(const Address4& address, const Port& port, const unsigned int timeout = 1000u) override;
45
46 /**
47 * Reconnects the client by the usage of the most recent address and port.
48 * @see ConnectionOrientedClient::connect().
49 */
50 bool connect(const unsigned int timeout = 1000u) override;
51
52 /**
53 * Disconnects the client.
54 * @see ConnectionOrientedClient::disconnect().
55 */
56 bool disconnect() override;
57
58 protected:
59
60 /**
61 * Build the TCP socket.
62 * @return True, if succeeded
63 */
65};
66
67}
68
69}
70
71#endif // FACEBOOK_NETWORK_TCP_CLIENT_H
This class wraps an address number with 32 bits.
Definition Address4.h:26
This class is the base class for all connection oriented clients.
Definition ConnectionOrientedClient.h:28
This class wraps a port number with 16 bits.
Definition Port.h:26
This class implements a TCP client.
Definition TCPClient.h:27
~TCPClient() override
Destructs a TCP client.
bool connect(const unsigned int timeout=1000u) override
Reconnects the client by the usage of the most recent address and port.
bool buildSocket()
Build the TCP socket.
bool disconnect() override
Disconnects the client.
TCPClient()
Creates a new TCP client.
bool connect(const Address4 &address, const Port &port, const unsigned int timeout=1000u) override
Connects to a TCP server.
The namespace covering the entire Ocean framework.
Definition Accessor.h:15