#pragma once

#include "TCPSocket.h"
#include "blitz/Defines.h"

namespace blitz {
namespace network {

class TCPListener {
	int m_Handle;
	std::uint16_t m_Port;
	int m_MaxConnections;

  public:
	TCPListener();
	~TCPListener();

	bool Listen(std::uint16_t port, int maxConnections);
	bool Accept(TCPSocket& newSocket);

	void Destroy();
	bool Close();
	bool SetBlocking(bool blocking);

	std::uint16_t GetListeningPort() const {
		return m_Port;
	}

	int GetMaximumConnections() const {
		return m_MaxConnections;
	}

	REMOVE_COPY(TCPListener);
};

}  // namespace network
}  // namespace blitz