TCPAcceptor.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright 2019 Proyectos y Sistemas de Mantenimiento SL (eProsima).
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #ifndef _FASTDDS_TCP_ACCEPTOR_BASE_
  15. #define _FASTDDS_TCP_ACCEPTOR_BASE_
  16. #include <asio.hpp>
  17. #include <fastdds/rtps/common/Locator.h>
  18. namespace eprosima{
  19. namespace fastdds{
  20. namespace rtps{
  21. class TCPTransportInterface;
  22. /**
  23. * Common class to wrap ASIO acceptors.
  24. */
  25. class TCPAcceptor
  26. {
  27. protected:
  28. asio::ip::tcp::acceptor acceptor_;
  29. fastrtps::rtps::Locator_t locator_;
  30. asio::ip::tcp::endpoint endpoint_;
  31. std::vector<fastrtps::rtps::Locator_t> pending_out_locators_;
  32. asio::io_service* io_service_;
  33. public:
  34. TCPAcceptor(
  35. asio::io_service& io_service,
  36. TCPTransportInterface* parent,
  37. const fastrtps::rtps::Locator_t& locator);
  38. TCPAcceptor(
  39. asio::io_service& io_service,
  40. const std::string& interface,
  41. const fastrtps::rtps::Locator_t& locator);
  42. const fastrtps::rtps::Locator_t& locator() const
  43. {
  44. return locator_;
  45. }
  46. fastrtps::rtps::Locator_t& locator()
  47. {
  48. return locator_;
  49. }
  50. virtual ~TCPAcceptor() = default;
  51. };
  52. } // namespace rtps
  53. } // namespace fastdds
  54. } // namespace eprosima
  55. #endif // _FASTDDS_TCP_ACCEPTOR_BASE_