Ocean
PackagedUDPServer.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_UDP_SERVER_H
9 #define FACEBOOK_NETWORK_PACKAGED_UDP_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 packaged UDP server.
22  * @ingroup network
23  */
24 class OCEAN_NETWORK_EXPORT PackagedUDPServer : virtual public PackagedConnectionlessServer
25 {
26  public:
27 
28  /**
29  * Creates a new UDP server object.
30  */
32 
33  /**
34  * Destructs a UDP server object.
35  */
36  ~PackagedUDPServer() override;
37 
38  /**
39  * Starts the server.
40  * @see Server::start().
41  */
42  bool start() override;
43 
44  /**
45  * Sets the own port of this socket.
46  * @see Socket::setPort().
47  */
48  bool setPort(const Port& port) override;
49 
50  protected:
51 
52  /**
53  * Creates a UDP server socket.
54  * @param localAddress The local address to which the socket will be bound, a default address to bound the socket to any local address
55  * @param localPort The local port to which the socket will be bound, a default port to bound the socket to any free port
56  * @return True, if succeeded
57  */
58  bool buildSocket(const Address4& localAddress = Address4(), const Port localPort = Port());
59 };
60 
61 
62 }
63 
64 }
65 
66 #endif // FACEBOOK_NETWORK_PACKAGED_UDP_SERVER_H
This class wraps an address number with 32 bits.
Definition: Address4.h:26
This class is the base class for all package connectionless server.
Definition: PackagedConnectionlessServer.h:31
This class implements a packaged UDP server.
Definition: PackagedUDPServer.h:25
PackagedUDPServer()
Creates a new UDP server object.
~PackagedUDPServer() override
Destructs a UDP server object.
bool buildSocket(const Address4 &localAddress=Address4(), const Port localPort=Port())
Creates a UDP server socket.
bool setPort(const Port &port) override
Sets the own port of this socket.
bool start() override
Starts the server.
This class wraps a port number with 16 bits.
Definition: Port.h:26
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15