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