Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
TcpServer.hpp
1 // Copyright (C) 2017 Jérôme Leclercq
2 // This file is part of the "Nazara Engine - Network module"
3 // For conditions of distribution and use, see copyright notice in Config.hpp
4 
5 #pragma once
6 
7 #ifndef NAZARA_TCPSERVER_HPP
8 #define NAZARA_TCPSERVER_HPP
9 
10 #include <Nazara/Prerequesites.hpp>
11 #include <Nazara/Network/AbstractSocket.hpp>
12 #include <Nazara/Network/IpAddress.hpp>
13 
14 namespace Nz
15 {
16  class TcpClient;
17 
18  class NAZARA_NETWORK_API TcpServer : public AbstractSocket
19  {
20  public:
21  inline TcpServer();
22  inline TcpServer(TcpServer&& tcpServer);
23  ~TcpServer() = default;
24 
25  bool AcceptClient(TcpClient* newClient);
26 
27  inline IpAddress GetBoundAddress() const;
28  inline UInt16 GetBoundPort() const;
29 
30  inline SocketState Listen(NetProtocol protocol, UInt16 port, unsigned int queueSize = 10);
31  SocketState Listen(const IpAddress& address, unsigned int queueSize = 10);
32 
33  private:
34  void OnClose() override;
35  void OnOpened() override;
36 
37  IpAddress m_boundAddress;
38  };
39 }
40 
41 #include <Nazara/Network/TcpServer.inl>
42 
43 #endif // NAZARA_TCPSERVER_HPP
TODO: Inherit SoundEmitter from Node.
Definition: Algorithm.hpp:12
Network class that represents an IP address.
Definition: IpAddress.hpp:21
Network class that represents a client in a TCP connection.
Definition: TcpClient.hpp:21
Network class that represents a server in a TCP connection.
Definition: TcpServer.hpp:18
Network class that represents the base of socket.
Definition: AbstractSocket.hpp:18