2 * Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include "anbox/network/local_socket_messenger.h"
19 #include "anbox/logger.h"
20 #include "anbox/network/socket_helper.h"
21 #include "anbox/utils.h"
23 #include <boost/system/error_code.hpp>
27 LocalSocketMessenger::LocalSocketMessenger(
28 std::shared_ptr<boost::asio::local::stream_protocol::socket> const &socket)
29 : BaseSocketMessenger(socket) {}
31 LocalSocketMessenger::LocalSocketMessenger(const std::string &path,
32 const std::shared_ptr<Runtime> &rt)
33 : socket_(std::make_shared<boost::asio::local::stream_protocol::socket>(
35 boost::system::error_code err;
36 socket_->connect(boost::asio::local::stream_protocol::endpoint(path), err);
38 const auto msg = utils::string_format("Failed to connect to socket %s: %s",
40 BOOST_THROW_EXCEPTION(std::runtime_error(msg));
46 LocalSocketMessenger::~LocalSocketMessenger() {}
47 } // namespace network