Line data Source code
1 : // Copyright 2025 Accenture. 2 : 3 : #pragma once 4 : 5 : #include "ip/IPAddress.h" 6 : #include "tcp/socket/AbstractSocket.h" 7 : 8 : #include <platform/estdint.h> 9 : 10 : namespace tcp 11 : { 12 : /** 13 : * Interface for classes that provide Sockets 14 : */ 15 : class ISocketProvidingConnectionListener 16 : { 17 : public: 18 2 : ISocketProvidingConnectionListener() = default; 19 : ISocketProvidingConnectionListener(ISocketProvidingConnectionListener const&) = delete; 20 : ISocketProvidingConnectionListener& operator=(ISocketProvidingConnectionListener const&) 21 : = delete; 22 : 23 : // [ISocketProvidingConnectionListener] 24 : /** 25 : * returns a pointer to a AbstractSocket object 26 : * \param ipAddr Ip address of client which tries to connect. 27 : * \param port Port of client from which it tries to connect. 28 : * \return 29 : * - pointer to AbstractSocket 30 : * - NULL if no more sockets are available 31 : */ 32 : virtual AbstractSocket* getSocket(ip::IPAddress const& ipAddr, uint16_t port) = 0; 33 : 34 : /** 35 : * callback being called when a TCP connection gets accepted 36 : * \param socket the AbstractSocket representing the connection 37 : * 38 : * Usually the ISocketConnectionListener sets an IDataListener to the 39 : * socket when the connection is established. 40 : */ 41 : virtual void connectionAccepted(AbstractSocket& socket) = 0; 42 : // [ISocketProvidingConnectionListener] 43 : }; 44 : 45 : } /*namespace tcp*/