TCPAcceptorBasic.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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_BASIC_
  15. #define _FASTDDS_TCP_ACCEPTOR_BASIC_
  16. #include <fastdds/rtps/transport/TCPAcceptor.h>
  17. #include <fastdds/rtps/transport/TCPChannelResourceBasic.h>
  18. namespace eprosima{
  19. namespace fastdds{
  20. namespace rtps{
  21. /**
  22. * Plain TCP Socket acceptor wrapper class.
  23. */
  24. class TCPAcceptorBasic : public TCPAcceptor
  25. {
  26. public:
  27. /**
  28. * Constructor
  29. * @param io_service Reference to the ASIO service.
  30. * @param parent Pointer to the transport that is going to manage the acceptor.
  31. * @param locator Locator with the information about where to accept connections.
  32. */
  33. TCPAcceptorBasic(
  34. asio::io_service& io_service,
  35. TCPTransportInterface* parent,
  36. const fastrtps::rtps::Locator_t& locator);
  37. /**
  38. * Constructor
  39. * @param io_service Reference to the ASIO service.
  40. * @param interface Network interface to bind the socket
  41. * @param locator Locator with the information about where to accept connections.
  42. */
  43. TCPAcceptorBasic(
  44. asio::io_service& io_service,
  45. const std::string& interface,
  46. const fastrtps::rtps::Locator_t& locator);
  47. /**
  48. * Destructor
  49. */
  50. virtual ~TCPAcceptorBasic()
  51. {
  52. acceptor_.cancel();
  53. acceptor_.close();
  54. }
  55. //! Method to start the accepting process.
  56. void accept(TCPTransportInterface* parent);
  57. private:
  58. asio::ip::tcp::socket socket_;
  59. };
  60. } // namespace rtps
  61. } // namespace fastdds
  62. } // namespace eprosima
  63. #endif // _FASTDDS_TCP_ACCEPTOR_BASIC_