Ocean
TCPServer.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_SERVER_H
9 #define FACEBOOK_NETWORK_TCP_SERVER_H
10 
11 #include "ocean/network/Network.h"
13 
14 namespace Ocean
15 {
16 
17 namespace Network
18 {
19 
20 /**
21  * This class implements a TCP server.
22  * @ingroup network
23  */
24 class OCEAN_NETWORK_EXPORT TCPServer : virtual public ConnectionOrientedServer
25 {
26  public:
27 
28  /**
29  * Creates a new TCP server.
30  */
32 
33  /**
34  * Destructs a TCP server.
35  */
36  ~TCPServer() override;
37 
38  /**
39  * Starts the server.
40  * Beware: If a specific listening port is expected the own port has to be set before
41  * @see Server::start().
42  */
43  bool start() override;
44 
45  /**
46  * Disconnects a specified connection.
47  * @see ConnectionOrientedServer::disconnect().
48  */
49  bool disconnect(const ConnectionId connection) override;
50 
51  protected:
52 
53  /**
54  * Builds the TCP socket.
55  * @return True, if succeeded
56  */
57  bool buildSocket();
58 };
59 
60 }
61 
62 }
63 
64 #endif // FACEBOOK_NETWORK_TCP_SERVER_H
This class is the base class for all connection oriented servers.
Definition: ConnectionOrientedServer.h:28
unsigned int ConnectionId
Definition of a connection id.
Definition: ConnectionOrientedServer.h:34
This class implements a TCP server.
Definition: TCPServer.h:25
~TCPServer() override
Destructs a TCP server.
bool buildSocket()
Builds the TCP socket.
TCPServer()
Creates a new TCP server.
bool start() override
Starts the server.
bool disconnect(const ConnectionId connection) override
Disconnects a specified connection.
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15